title: Rails - strong params removing empty fields from nested attributes
body: <p>I have been working on this line of code for three days.
  I have the following strong params: </p>
  
  <pre><code>def location_params
    params.require(:location).permit(:country, {:ads_attributes =&gt; [:remote, :days]})
  end
  </code></pre>
  
  <p>The method <em>param_clean</em> will delete from the <em>location_params</em> the empty fields, but it will not work with the nested <strong>:ads_attributes</strong>.
  The main reason is that <strong>param_clean</strong> can only be called on <strong>location_params</strong> that has class <strong>ActiveController::Parameters</strong>. I can not call on <strong>v</strong> the method <strong>param_clean</strong></p>
  
  <pre><code>def param_clean
      location_params.delete_if{  |k, v| v.empty? or v.instance_of?(ActionController::Parameters) &amp;&amp; v.param_clean.empty? }
  end 
  </code></pre>
  
  <p>I receive the following error</p>
  
  <pre><code>undefined method `param_clean' for #&lt;ActionController::Parameters:0x007f..&gt;
  </code></pre>
  
  <p>This is the value of location_params</p>
  
  <pre><code>&lt;ActionController::Parameters {"country"=&gt;"", "ads_attributes"=&gt;&lt;ActionController::Parameters {"remote"=&gt;"0", "days"=&gt;""} permitted: true&gt;} permitted: true&gt;
  </code></pre>
  
  <p>This is the value of <code>v</code> variable when the error is triggered</p>
  
  <pre><code>&lt;ActionController::Parameters {"remote"=&gt;"0", "days"=&gt;""} permitted: true&gt;
  
  v.class =&gt; ActionController::Parameters
  </code></pre>
  
  <p>The method does not work with the nested parameters.
  Thanks a lot for your help</p>
  
  <p>Best Regards
  Fabrizio</p>