0

Running Locally Rails 5.2.6 Ruby 2.5.1p57 upgraded from Rails 5.1.7 (everything worked fine before upgrading)

ActionView::Template::Error (unable to convert unpermitted parameters to hash):
     6:   <ul class="dropdown-menu" role="menu">
     7:     <% choices.each do |c| %>

     8:       <li class="<%= "active" if params[:sort] == "#{c[0]}-#{c[1]}" %>">
     9:       <%= link_to url_for(params.merge(sort: "#{c[0]}-#{c[1]}")) do %>
    10:         <%= c[0].humanize %> <i class="fa fa-long-arrow-<%= c[1] == 'asc' ? 'up' : 'down' %>"></i>
    11:       <% end %>
    12:       </li>

app/views/shared/_sort_dropdown.html.erb:9:in `block in _app_views_shared__sort_dropdown_html_erb___1598759478239571724_70137340818660'
app/views/shared/_sort_dropdown.html.erb:7:in `each'
app/views/shared/_sort_dropdown.html.erb:7:in `_app_views_shared__sort_dropdown_html_erb___1598759478239571724_70137340818660'
app/views/films/index.html.erb:6:in `block in _app_views_films_index_html_erb___3440113417390236014_70137340622600'
app/views/films/index.html.erb:1:in `_app_views_films_index_html_erb___3440113417390236014_70137340622600'
app/controllers/application_controller.rb:33:in `set_tenant_time_zone'

app/views/shared/_sort_dropdown.html.erb

<div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
    Sort: <strong><%= current[0].humanize %> <i class="fa fa-long-arrow-<%= current[1] == 'asc' ? 'up' : 'down' %>"></i></strong> 
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu">
    <% choices.each do |c| %>
      <li class="<%= "active" if params[:sort] == "#{c[0]}-#{c[1]}" %>">
      <%= link_to url_for(params.merge(sort: "#{c[0]}-#{c[1]}")) do %>
        <%= c[0].humanize %> <i class="fa fa-long-arrow-<%= c[1] == 'asc' ? 'up' : 'down' %>"></i>
      <% end %>
      </li>
    <% end %>
  </ul>
</div>

This is a button that sorts the data

Inside index.html.erb

<%= render 'shared/sort_dropdown', current: sort, choices: [['serial','desc'], ['area','asc'], ['shelf','asc']] %> 
Stephanie
  • 105
  • 1
  • 10
  • https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-to_unsafe_h – engineersmnky Sep 10 '21 at 20:25
  • 1
    looks as if you're trying to access the params hash directly in the view. You shouldn't do this, instead, 'sanitize' the params using the strong_parameters technique https://api.rubyonrails.org/classes/ActionController/StrongParameters.html. Also, stylistically, it's unusual to access params (or strong params) in the view. Normally it should be built on model instances. But you haven't shared enough of your app for us to understand what the controller is doing here. – Les Nightingill Sep 10 '21 at 22:11
  • The issue is covered in this question pretty well in this answer: https://stackoverflow.com/a/46029524/716 – roo Sep 11 '21 at 08:06

0 Answers0