我正在使用locals参数渲染smart_listing部分视图:
smart_listing_render(:user_ldaproles, locals: {ldapuser: @ldapuser})
局部参数ldapuser
适用于呈现的第一个页面。
但是,当我单击smart_listing处的下一页时,本地参数ldapuser
是nil
。
13:05:52 web.1 | Started GET "/ldapusers/kru0096?user_ldaproles_smart_listing%5Bpage%5D=2" for 10.0.1
13:27:09 web.1 | Rendered ldapusers/show.js.erb (1946.1ms)
13:27:09 web.1 | Completed 500 Internal Server Error in 1980ms (ActiveRecord: 4.2ms)
13:27:09 web.1 |
13:27:09 web.1 |
13:27:09 web.1 |
13:27:09 web.1 | NameError - undefined local variable or method `ldapuser' for #<#<Class:0x00007f4f6c
bb2638>:0x00007f4f6d4a5ab0>
13:27:09 web.1 | Did you mean? @ldapuser:
13:27:09 web.1 | app/views/ldapusers/_ldaproles.haml:24:in `block in _app_views_ldapusers__ldaprole
s_haml__4226213442704361194_69988992008260'
13:27:09 web.1 | app/views/ldapusers/_ldaproles.haml:10:in `_app_views_ldapusers__ldaproles_haml__4
226213442704361194_69988992008260'
13:27:09 web.1 | app/views/ldapusers/show.js.erb:2:in `_app_views_ldapusers_show_js_erb__8937577382
81268117_69989556369100'
我可以使用全局参数@ldapuser
,但是gem rails_best_practicies
不喜欢它。
当转到下一页时,如何获取传递给smart_listing_render
的局部参数以保持其值?
app/views/ldapusers/show.js.erb:
<%= smart_listing_update :user_ldaproles %>
答案 0 :(得分:0)
我的app/views/ldapusers/show.js.erb
文件中有问题。
该文件还必须更新本地参数。
<%= smart_listing_update :user_ldaproles, locals: {ldapuser: @ldapuser} %>
然后进行分页工作。