问题描述
在控制器端,我有一个数组
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)
然后在视图中我有这个渲染标签,我想通过它渲染@bookmarks
Then at the View I have this render tag through which I want to render @bookmarks
然后是_bookmark 的页面,将显示@bookmarks
Then there is page for _bookmark which will display @bookmarks
bookmark.title
bookmark.created_at
但是这个过程给了我不偏不倚的错误.(我尝试通过 Ajax 实现 kaminari)
But this process is giving me error of no partial. (I try to implement kaminari via Ajax)
推荐答案
使用这样的 render 方法会导致它在 bookmarks/_bookmark 中寻找部分.
using the render method like that will 'cause it to look for a partial in bookmarks/_bookmark.
您还可以使用 render partial: 'folder/mypartial', collection: @bookmarks
这篇关于在 ruby on rails 视图中渲染数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!