Q:

Rails, devise, current_user get posts.name

I have Post model which is associated with devise's User. I want to know names of the posts user has when logged in.
  <% @posts.each do |post| %>
     <% if user_signed_in? %> 
        <%= current_user.posts.name %>
     <% end %>
   <% end %>

Why this doesn't giving me a post name? and how to make it right? 

A:

If your models relation is user has_many posts then only use following code. It may works
     <% if user_signed_in? %> 
        <%= current_user.posts.each do |post| %>
         <%= post.name %>
        <% end %>
     <% end %>

