User
- has_many :communities
- has_many :posts
Community
- belongs_to :user
- has_many :posts
Post
- belongs_to :user
- belongs_to :community
I'd like to show all the records of Posts at example.com/posts
But it has to be sorted by Post owner User's 'last_signed_in' column which is in Users table.
I tried this but this returns error undefined method `users' How can I solve?
@orders = @community.posts.user.order("last_active_at ASC")