Render an array in a view in ruby on rails

微笑、不失礼 提交于 2019-12-12 03:05:38

问题


At the controller end, I have an array

@bookmarks = Bookmark.where('user_id = ? && note is NULL',current_user.id).order('created_at DESC').page(params[:page_2]).per(4)

Then at the View I have this render tag through which I want to render @bookmarks

<%= render @bookmarks %>

Then there is page for _bookmark which will display @bookmarks

bookmark.title 
bookmark.created_at

But this process is giving me error of no partial. (I try to implement kaminari via Ajax)


回答1:


using the render method like that will 'cause it to look for a partial in bookmarks/_bookmark.

you can also specify the partial and collection with render partial: 'folder/mypartial', collection: @bookmarks



来源:https://stackoverflow.com/questions/9014923/render-an-array-in-a-view-in-ruby-on-rails

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