Undefined method permit for string
<p>I'm currently designing and implementing a RoR API.</p>

<p>I'm facing an issue concerning strong parameters.</p>

<p>I'm expecting to receive the following attributes:</p>

<pre><code>{ analysis_data: { barcode: "some_string" } }
</code></pre>

<p>To ensure that, I simply use the require/permit combination:</p>

<pre><code>params.require(:analysis_data).permit(:barcode)
</code></pre>

<p>This works well if analysis data is nil or an hash.</p>

<p>However, if the client submit a request where analysis_data is a string instead of an hash, the request returns an error 500.</p>

<p>For example:</p>

<pre><code> { analysis_data: "some_string" }
</code></pre>

<p>Produces the following 500 error:</p>

<pre><code> NoMethodError (undefined method `permit' for "barcode":String):
</code></pre>

<p>Is there any <code>clean</code> workaround?</p>