How to render collection with template in rails3?

给你一囗甜甜゛ 提交于 2019-12-25 04:59:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!