David_Zhu
(David Zhu)
April 12, 2010, 12:28am
1
Hello,
I'm sure all of you have done this before,
basically users can post new posts, but i want their names next to the
post.
I have a current_user helper method, but i dont know how to display a
static one next to that one post.
Anyhelp would be appreciated thanks
11155
(-- --)
April 12, 2010, 5:48am
2
Hi,
      As you want to display owner of post next to the post. Use
post.user.name to display owner of the post. I think there is one to
many relation exist between user & post model.
user has_many Post .
post has_one user .
Veeraa
(Veeraa)
April 14, 2010, 6:25am
4
yes as per first reply you should have has_many and belongs_to relationship between user and post.
user has_many posts
post belongs_to user
so that you can get post.user.name etc.