Rails3: If X belong_to Y, how do I display all X regardless of Y?
I am experimenting to create something similar to Twitter.
In my app, posts belong to users, and users has many posts.
Now, I 开发者_StackOverflow中文版know how to display posts of one particular user sorted by submission time.
But I am not sure how to display all posts of all users in one page sorted by submission time.
Any idea?
Post.order(:submission_time)
Something like the following?
def stream
@post = Post.order("created_at DESC")
end
Or am I misunderstanding you?
精彩评论