问题
If there is a _post.html.erb in app/views/posts/, I can input <%= render @posts %>
in app/views/posts/index.html.erb , but if the _post.html.erb file in app/views/users/posts/, how to write?
I tried <%= render @posts, :template => 'users/posts/post' %>
, but it does not work.
回答1:
<%= render :partial => 'users/posts/post', :collection => @posts %>
来源:https://stackoverflow.com/questions/10916851/how-to-render-collection-with-template-in-rails3