title: pass array hidden field in nested model rails
body: <p>I have following code in my view:</p>
  
  <pre><code>    &lt;% @m1.map(&amp;:id).each do |id|%&gt;
  
      &lt;%= b.fields_for :modul1hours do |f| %&gt;
  
      &lt;%= f.hidden_field :modul1_id, id %&gt;
      &lt;%= f.text_field :module_est_hours, :size =&gt; 30 %&gt;
      &lt;/tr&gt;
    &lt;% end %&gt;
  
  &lt;%end%&gt;
  </code></pre>
  
  <p>params passing in console</p>
  
  <pre><code>Parameters: {"authenticity_token"=&gt;"LJ/ZME2lHZ7VwCDgPKX6OFe326fXSXo5UB4M0cPwbCE=", "esthour"=&gt;{"rfp_id"=&gt;"6", "ecommerce_est_hours"=&gt;"", "modul1hours"=&gt;{"module_est_hours"=&gt;"3"}, "designpages_est_hours"=&gt;"", "cms_est_hours"=&gt;""}, "modul1_ids"=&gt;["12", "13", "14"], "utf8"=&gt;"✓", "project_id"=&gt;"second", "commit"=&gt;"Add Todo"}
  </code></pre>
  
  <blockquote>
    <p>Current user: admin (id=1)</p>
    
    <p>modul1_ids is the hidden array based on that three text box is created but when i submit the page gives me:</p>
  </blockquote>
  
  <pre><code>ActionView::Template::Error (undefined method `merge' for 12:Fixnum):
  </code></pre>
  
  <p>in first textbox i passed 1
      second                2
      and in third          3</p>
  
  <p>last value(3) isthe s passing that one can see in the console params <code>module_est_hours"=&gt;"3</code>, but what about rest two fields y not passing and whats the solution for an error. Please help me.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <pre><code>    &lt;% @m1.map(&amp;:id).each do |id|%&gt;
  
      &lt;%= b.fields_for :modul1hours do |f| %&gt;
  
      &lt;%= hidden_field_tag "modul1_ids[]", id %&gt;
      &lt;%= f.text_field :module_est_hours, :size =&gt; 30 %&gt;
      &lt;/tr&gt;
    &lt;% end %&gt;
  
  &lt;%end%&gt;
  </code></pre>
  
  <p>this code does not give the error, but also value is not stored in <code>modul1hours</code> table</p>
  
  <p>The field of the <code>modul1hours</code> table are:</p>
  
  <pre><code>integer :modul1_id
  decimal :module_est_hours
  decimal :module_act_hours
  integer :esthours_id
  </code></pre>
  
  <p>]</p>
  
  <p>.rb</p>
  
  <p>belongs_to :esthour</p>
  
  <p>attr_accessible :module_est_hours,:module_act_hours</p>
  
  <p>and controller</p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>    def new
  @esthour = Esthour.new
   @gg =  @esthour.modul1hours.build
  @project = params[:project_id]
  @rfp = params[:rfp_id]
  
  @m1 = Modul1.where(:rfp_id =&gt; @rfp.id)
  
  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json =&gt; @esthour }
  end
  </code></pre>
  
  <p>end
  <strong>over Update</strong>
    # GET /project_todos/1/edit</p>
  
  <pre><code>      def edit
        @esthour = Esthour.find(params[:id])
        end
  
  
             def create
  
              @project = params[:project_id]
  
  
              @esthour = Esthour.new(params[:esthour])
  
              user_params = params.select{|k,v| k.include?('esthour')}
  
              respond_to do |format|
  
             if @esthour.save
  
         get_issue_attribute_param1(user_params)
  
               format.html { redirect_to project_rfp_url(@project,@esthour.rfp_id), :notice =&gt; 'hours was successfully created.' }
              format.json { render :json =&gt; @esthour, :status =&gt; :created, :location =&gt; @esthour }
    else
              format.html { render :action =&gt; "new" }
              format.json { render :json =&gt; @esthour.errors, :status =&gt; :unprocessable_entity }
    end
  end
   end
  </code></pre>
  
  <p><em>is there any build needed?eg Esthour.modul1hour.build in new def of controller coz record not saved in table?</em> </p>
  
  <p>view</p>
  
  <pre><code>    &lt;%= form_for @esthour,:rfp_id =&gt; @rfp.id,:project_id =&gt; @project do |b| %&gt;
  
      &lt;%= b.hidden_field :rfp_id, :value =&gt; @rfp.id %&gt;
  
      &lt;%= hidden_field_tag :project_id, @project %&gt;
     &lt;table&gt;
        &lt;tr&gt;    &lt;td&gt;&lt;b&gt;Menutype &lt;/b&gt;&lt;/td&gt;
      &lt;% if  @rfp.menutype.present? %&gt;
          &lt;td&gt;&lt;%= @rfp.menutype %&gt;&lt;/td&gt; 
          &lt;td&gt;&lt;%= b.number_field :menutype_est_hours %&gt;&lt;/td&gt;
      &lt;% end %&gt;
  &lt;/tr&gt;
  
        &lt;tr&gt;           &lt;td&gt; &lt;b&gt;Number of menu&lt;/b&gt; &lt;/td&gt;
      &lt;% if  @rfp.numberofmenu.present? %&gt;
          &lt;td&gt;&lt;%= @rfp.numberofmenu %&gt;&lt;/td&gt; 
          &lt;td&gt;&lt;%= b.number_field :numberofmenu_est_hours %&gt;&lt;/td&gt;
      &lt;% end %&gt;
     &lt;/tr&gt;
  
      &lt;tr&gt;
  
          &lt;% @m1.map(&amp;:id).each do |id|%&gt;
  
           &lt;%= b.fields_for :modul1hours do |f| %&gt;
  
  
            &lt;%= f.hidden_field :modul1_id, value =&gt; id  %&gt;
            &lt;%= f.text_field :module_est_hours, :size =&gt; 30 %&gt;
           &lt;/tr&gt;
        &lt;% end %&gt;
  
       &lt;% end %&gt;
  
  
  
        &lt;/table&gt;
       &lt;%= b.submit 'Add Todo' %&gt;
       &lt;% end %&gt;
  
  
       @esthour = Esthour.new
  
           @gg =  @esthour.modul1hours.build
         @project = params[:project_id]
  </code></pre>