display USERNAME next to post

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 :slight_smile: thanks

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 .

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.