Note that there are some explanatory texts on larger screens.

plurals
  1. POexpected Hash (got Array) for param 'samples'
    primarykey
    data
    text
    <p>I have been following Railscasts episodes of Nested forms and complex forms. During the time of creating multiple model in a single form I was able to edit, update, delete and create records for sample models that were nested in the Batch model. </p> <p>I have been breaking my head from a long time and tried searching around as well but could not get any right solution for solving this problem.</p> <p>my development log file gives me the following error.</p> <p>ERROR MESSAGE:</p> <pre><code>Status: 500 Internal Server Error expected Hash (got Array) for param `samples' </code></pre> <p>in my controller I have the update action like this </p> <pre><code>def update @batch = Batch.find(params[:id]) respond_to do |format| if @batch.update_attributes(params[:batch]) flash[:notice] = 'Successfully updated Batch.' format.html { redirect_to(@batch) } format.xml { head :ok } else format.html { render :action =&gt; "edit" } format.xml { render :xml =&gt; @batch.errors, :status =&gt; :unprocessable_entity } end end end </code></pre> <p>my view is something like this:</p> <pre><code>&lt;%= form_for @batch do |f| %&gt; ...... &lt;%= f.fields_for :samples do |s_form| %&gt; .... s_form things &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p>my model contains the same stuff :</p> <pre><code>has_many :samples, :dependent =&gt; :destroy accepts_nested_attributes_for :samples, :reject_if =&gt; lambda { |a| a[:content].blank? }, :allow_destroy =&gt; true </code></pre> <p>All suggestions are appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload