title: Rails Unable to convert unpermitted parameters to hash
body: <p>I am trying to implement a simple search and sort for my webapp. I am following the <a href="http://railscasts.com/episodes/240-search-sort-paginate-with-ajax" rel="noreferrer">railscast</a> and this <a href="http://railscasts.com/episodes/37-simple-search-form" rel="noreferrer">railscast</a>. </p>
  
  <p>My application helper for sortable function which I am using as link is:</p>
  
  <pre><code>def sortable(column, title = nil)
        title ||= column.titleize
        css_class = column == sort_column ? "current #{sort_direction}" : nil
        direction = column == sort_column &amp;&amp; sort_direction == "asc" ? "desc" : "asc"
        link_to title, params.merge(:sort =&gt; column, :direction =&gt; direction, :page =&gt; nil), {:class =&gt; css_class}
      end
  </code></pre>
  
  <p>I am using these in the view. In the controller I am using white listing as:</p>
  
  <pre><code> @listingssearch.where(:vehicletype =&gt; 'Car').order(sort_column + " " + sort_direction).paginate(:page =&gt; params[:page], :per_page =&gt; 30)
  </code></pre>
  
  <p>Private Methods for sanitization:</p>
  
  <pre><code> private
       def sort_column
            Listing.column_names.include?(params) ? params[:sort] : "rateperhour"
          end
  
          def sort_direction
            %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
          end
  </code></pre>
  
  <p>I tried using merge in the private method:</p>
  
  <pre><code>(Listing.column_names + params) but its not working 
  </code></pre>
  
  <p>For the helper methods <strong>I am getting an error when I am trying to provide search params</strong> to the sorting link: unable to convert unpermitted parameters to hash</p>
  
  <p>It shows the error is for merge</p>
  
  <pre><code>link_to title, params.merge(:sort =&gt; column, :direction =&gt; direction, :page =&gt; nil), {:class =&gt; css_class}
  </code></pre>
  
  <p>The otherway around works fine:</p>
  
  <pre><code>&lt;%= bootstrap_form_for listings_path, :method =&gt; 'get' do %&gt;
  
          &lt;%= hidden_field_tag :direction, :value =&gt; params[:direction] %&gt;
          &lt;%= hidden_field_tag :sort,:value =&gt; params[:sort] %&gt;
  
  
  
          &lt;div class= "col-sm-12 col-lg-12 col-md-12" style = "margin: auto;"&gt;
              &lt;h6 style = "color:#7C064D;"&gt;&lt;strong&gt; PICK A DATE  &lt;span class="glyphicon glyphicon-calendar"&gt;&lt;/span&gt;&lt;/strong&gt;
              &lt;%= date_field_tag :startdate, params[:startdate], placeholder: 'DATE' %&gt;           
              &lt;/h6&gt;
          &lt;/div&gt;  
  
          &lt;div class= "col-sm-12 col-lg-12 col-md-12" style = "margin: auto;"&gt;    
          &lt;p&gt;     
              &lt;%= text_field_tag :near, params[:near], placeholder: ' Destination' %&gt;
              &lt;%= text_field_tag :radius, params[:radius], placeholder: ' Search Radius' %&gt;
          &lt;/p&gt;
          &lt;/div&gt;      
          &lt;div class= "col-sm-12 col-lg-12 col-md-12" style = "margin: auto;"&gt;    
          &lt;p&gt;     
              &lt;%= text_field_tag :min, params[:min], placeholder: ' Minimum Rate Per Hour' %&gt;
              &lt;%= text_field_tag :max, params[:max], placeholder: ' Maximum Rate Per Hour' %&gt;
          &lt;/p&gt;
          &lt;/div&gt;
  
          &lt;div class= "col-sm-12 col-lg-12 col-md-12" style = "margin-top: 10px;"&gt;        
              &lt;%= submit_tag "Search", class: "btn btn-info", style: "width: 40%; background-color: #E20049; border: #e20049;" %&gt;
              &lt;%= link_to 'View All', root_path, class: "btn btn-info", style: "width: 40%; background-color: #E20049; border: #e20049;" %&gt;
          &lt;/div&gt;
  
          &lt;!-- &lt;div class= "col-sm-6 col-lg-6 col-md-6" style = "margin-top: 10px;"&gt;      
  
          &lt;/div&gt; --&gt;
  
  
      &lt;% end %&gt;
  </code></pre>
  
  <p><strong>My question is How to persist search params in sort helper methods in rails 5? What I am doing wrong?</strong></p>