title: how to pass argument from form_for method to controller method in rails?
body: <p>I have a bootstrap modal, when i clicked on the button then this bootstrap model will be called (open popup menu) and pass different-different <strong>offer_id's</strong>. </p>
  
  <p>this popup menu open a form(like edit form), I edited all information then click on <strong>edit button</strong> then only first records is updated.</p>
  
  <p>for example I want to edit information of <strong>offer_id = 1</strong>, when fill all form and submit then <strong>offer_id = 1</strong> is updated <strong>not offer_id = 5</strong>.</p>
  
  <p>so i don't know exactly where am i wrong, and what am i missing..</p>
  
  <p>edit button and model on the same page (<strong>_employee_details.html.erb</strong>) </p>
  
  <p><strong>edit button</strong> </p>
  
  <pre><code>&lt;div class="edit-recr-wrp1"&gt; 
         &lt;button type="button" class="btn btn-primary fa fa-pencil-square-o" data-toggle="modal" data-target="#exampleModal1" data-offer_id="&lt;%= emp['offer_letter_id'] %&gt;" data-employee_id="&lt;%= emp['employee_id'] %&gt;"&gt;&lt;/button&gt;               
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>modal "#exampleModal1"</strong></p>
  
  <pre><code>    &lt;div class="modal fade" id="exampleModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;h2 class="text-center"&gt;Edit &lt;span&gt;Employee Details&lt;/span&gt;&lt;/h2&gt;
          &lt;div class="post-new-job head-border"&gt;
            &lt;div class="alert alert-success" role="alert" id='success-job' style='display:none;'&gt;Employee Details is successfully added.&lt;/div&gt;
              &lt;div class="form-body"&gt; 
  
                  &lt;%= form_for :employee_details, :url =&gt;{:controller =&gt; "hr", :action =&gt; "update" } do |f| %&gt;                
                      &lt;div class="col-md-12"&gt;
  
                       &lt;div class="mydata1"&gt;
                         &lt;%= f.text_field :offer_letter_id, { class: 'form-control', id: 'offer_id-name' } %&gt;
                       &lt;/div&gt;
  
                       &lt;div class="form-group"&gt;
                          &lt;label class="control-label"&gt;Employee ID&lt;/label&gt;
                          &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt; &lt;i class="fa fa-user"&gt;&lt;/i&gt; &lt;/span&gt;
                          &lt;div class="mydata2"&gt;
                            &lt;%= f.text_field :employee_id, { disabled: true, :required =&gt; true, placeholder: 'E12345678', class: 'form-control', id: 'employee_id-name' } %&gt;
                          &lt;/div&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
  
                        &lt;div class="form-group"&gt;
                          &lt;label class="control-label"&gt;Bank Account&lt;/label&gt;
                          &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt; &lt;i class="fa fa-university"&gt;&lt;/i&gt; &lt;/span&gt;
                            &lt;%= f.text_field :bank_ac, { :required =&gt; true, placeholder: '06464060852634865', class: 'form-control' } %&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
  
                        &lt;div class="form-group"&gt;
                          &lt;label class="control-label"&gt;Bank IFSC Code&lt;/label&gt;
                          &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt; &lt;i class="fa fa-code"&gt;&lt;/i&gt; &lt;/span&gt;
                            &lt;%= f.text_field :bank_ifsc, { :required =&gt; true,  placeholder: 'SBI012356', class: 'form-control' } %&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
  
                       &lt;div class="form-group"&gt;
                          &lt;label class="control-label"&gt;End of Date&lt;/label&gt;
                          &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt; &lt;i class="fa fa-calendar"&gt;&lt;/i&gt; &lt;/span&gt;
                            &lt;%= f.text_field :work_end_date, {  placeholder: 'MM/DD/YYYY', id: 'datepicker1', class:"datepicker_style" } %&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
  
                        &lt;div class="form-group"&gt;
                          &lt;label class="control-label"&gt;Gender&lt;/label&gt;
                          &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt; &lt;i class="fa fa-male fa-female"&gt;&lt;/i&gt; &lt;/span&gt;
                            &lt;%= f.select :gender, ['Male', 'Female'], { :required =&gt; true }, class: "form-control" %&gt;
                          &lt;/div&gt; 
                        &lt;/div&gt;
  
                        &lt;div class="form-group"&gt;
                          &lt;label class="control-label"&gt;Spouse Name&lt;/label&gt;
                          &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt; &lt;i class="fa fa-user"&gt;&lt;/i&gt; &lt;/span&gt;
                            &lt;%= f.text_field :spouse_name, { :required =&gt; true, placeholder: 'Father/Mother/Wife name', class: "form-control" } %&gt;
                          &lt;/div&gt;
                        &lt;/div&gt; &lt;br&gt;
  
                        &lt;div class="form-group"&gt;
                          &lt;a&gt;&lt;%= f.submit "Edit Employee Details", :class =&gt; "btn btn-primary" %&gt;&lt;/a&gt; 
                        &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="col-md-2"&gt;&lt;/div&gt;                
                  &lt;%- end -%&gt;
              &lt;/div&gt;      
          &lt;/div&gt;
         &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      // edit employee information
      $('#exampleModal1').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget)
        var offer_id = button.data('offer_id')
        var employee_id = button.data('employee_id')
        var modal = $(this)
        modal.find('.mydata1 input').val(offer_id)
        modal.find('.mydata2 input').val(employee_id)
      });
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      // edit employee information
      $(document).ready(function () {        
          $('#datepicker1').datepicker({
              format: "dd/mm/yyyy"
          });    
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>hr_controller.rb</strong></p>
  
  <p>class HrController &lt; ApplicationController  </p>
  
  <pre><code>    def new
          @employees = EmployeeDetail.new
      end
  
      # edit employee information
      def edit
          @employees = EmployeeDetail.find_by(params[:offer_letter_id])
      end
  
      def create
          @employees = EmployeeDetail.new(employee_params)
          if @employees.save
              redirect_to :action =&gt; 'internal_employee_page'
          else
              redirect_to :action =&gt; 'internal_employee_page'
          end
      end
  
      def show
          @employees = EmployeeDetail.find(params[:id])
      end
  
      def update
          @employees = EmployeeDetail.find_by(params[:offer_letter_id])
  
          if @employees.update(employee_params)
              redirect_to :action =&gt; 'internal_employee_page'
          else
              redirect_to :action =&gt; 'internal_employee_page'
          end
      end
  
      private
  
          def employee_params
               params.require(:employee_details).permit(:offer_letter_id, :employee_id, :bank_ac, :bank_ifsc, :spouse_name, :gender, :work_end_date)
          end     
  end
  </code></pre>
  
  <p><strong>routes.rb</strong></p>
  
  <pre><code>  resources :hr
    get 'hr/edit'
    post 'hr/update'
  </code></pre>