Closed Kani999 closed 6 years ago
I'm rendering smart_listing_render with local parameter user.
smart_listing_render
user
.page-header %h2 Rolify - Roles = smart_listing_controls_for(:rolify_roles, class: 'form-inline text-right') do .form-group.filter.input-append = text_field_tag :filter, '', class: 'search form-control', placeholder: 'Search...', autocomplete: :off %button.btn.btn-primary.disabled{ type: 'submit' } %span.glyphicon.glyphicon-search = smart_listing_render(:rolify_roles, locals: { user: @user })
The page is loaded fine, but when I hit Next button, the local variable is unknown.
Next
12:01:17 web.1 | 12:01:17 web.1 | 12:01:17 web.1 | 12:01:17 web.1 | NameError - undefined local variable or method `user' for #<#<Class:0x00007f09b7577520>:0x00007f09b7083de8> 12:01:17 web.1 | Did you mean? @user: 12:01:17 web.1 | app/views/users/_rolify_roles.html.haml:25:in `block in _app_views_users__rolify_roles_html_haml___3348197901261425424_69839850803520' 12:01:17 web.1 | app/views/users/_rolify_roles.html.haml:12:in `_app_views_users__rolify_roles_html_haml___3348197901261425424_69839850803520' 12:01:17 web.1 | app/views/users/show.js.erb:2:in `_app_views_users_show_js_erb__3214774511846350922_69839851120280' 12:01:17 web.1 |
user.id is unknown when navigating to another page.
user.id
- smart_listing.collection.each do |role| %tr %td = role.id %td = role.name %td - unless role.resource_type.blank? = resource_type_path(role) %td - unless role.resource_id.blank? = resource_id_path(role) %td = link_to '', user_role_path(user.id, role.id),
Solved!
https://stackoverflow.com/questions/51100434/smart-listing-locals-params-does-not-work/51100872#51100872
I did not expect that js.erb file has to contain the local parameter too
js.erb
<%= smart_listing_update :rolify_roles, locals: { user: @user} %>
I'm rendering
smart_listing_render
with local parameteruser
.The page is loaded fine, but when I hit
Next
button, the local variable is unknown.user.id
is unknown when navigating to another page.