title: Rails: Error on 'NoMethodError (undefined method `underscore' for nil:NilClass):'
body: <p>I got an error while I'm updating my family_member_attributes.
  It say's on the terminal:</p>
  
  <pre><code>NoMethodError (undefined method `underscore' for nil:NilClass):
    app/controllers/clients_controller.rb:345:in `client_params'
    app/controllers/clients_controller.rb:123:in `block in update_children'
    app/controllers/clients_controller.rb:122:in `update_children'
  </code></pre>
  
  <p>Here's my controller:</p>
  
  <pre><code>  def update_children
      binding.pry
      @client = Client.find(params[:id])
      respond_to do |format|
        if @client.update_attributes(client_params)
          flash[:success] = 'Children Information was successfully updated.'
          format.js {
            render :js =&gt; "window.location = '#{legal_problem_client_path}'"
          }
        else
          format.json { render json: @client.errors, status: :unprocessable_entity }
        end
       end
    end
  </code></pre>
  
  <p>and this is my client_params</p>
  
  <pre><code>  def client_params
      binding.pry
      if params[:client].nil?
        params_require = params[:type].underscore.to_sym
      else
        params_require = 'client'.to_sym
      end
  
      params.require(params_require).permit(
        :first_name,
        :middle_name,
        :last_name,
        :company_name,
        :address,
        :mobile_no,
        :telephone_no,
        :email,
        :type,
        :status,
        :point_of_contact,
        :legal_problem,
        :objectives,
        :questions,
        :alternate_email,
        :address_abroad,
        :gender, (and so on)
  </code></pre>
  
  <p>I got an error in in <code>params_require = params[:type].underscore.to_sym</code> because it says that type is nil even I have value for params :type</p>
  
  <p>this is my form:</p>
  
  <pre><code>.box-content
    = form_for(@client, url: update_children_client_path, html: { class: 'form-horizontal', style: 'margin-bottom: 0;' }) do |f|
      = f.hidden_field :is_form_complete, value: false
      - if FamilyMember.name.present?
        = render partial: 'children_list'
      = add_children "Add", f, :family_members, 'children'
      .form-actions.form-actions-padding-sm
        .row
          .col-md-10.col-md-offset-2
            = f.submit "Next", class: "btn btn-lg btn-primary"
  </code></pre>
  
  <p>And this is the partial:</p>
  
  <pre><code>  %tbody
      %tr
        %td
          = f.text_field :name, class: 'form-control'
        %td
          = f.collection_select :children_gender, User::GENDER, :to_s, :titleize, { prompt: true }, { class: 'form-control' }
        %td{:style=&gt; "width: 200px; "}
          .form-group
            .container
              .datetimepicker.input-group.date
                = f.text_field :children_birthdate, class: 'form-control', data: { format: "yyyy-MM-dd" }, placeholder: "Select date", :readonly =&gt; 'readonly'
                %span.input-group-addon
                  %span.icon-calendar{"data-date-icon" =&gt; "icon-calendar", "data-time-icon" =&gt; "icon-time"}
        %td
          = f.text_field :children_school, class: 'form-control'
        %td
          = f.text_field :grade_year, class: 'form-control'
          = f.hidden_field :type, value: 'Individual', class: 'form-control'
        %td
  </code></pre>
  
  <p>heres's my parameters:</p>
  
  <pre><code>=&gt; {"utf8"=&gt;"✓",
   "_method"=&gt;"patch",
   "authenticity_token"=&gt;"FnQNiaE5GU4Ivilzi10XuK19GsGYKDirxJd/j7GQ4oI=",
   "individual"=&gt;
    {"is_form_complete"=&gt;"false",
     "family_members_attributes"=&gt;
      {"1406548379040"=&gt;
        {"name"=&gt;"afasfasf",
         "children_gender"=&gt;"",
         "children_birthdate"=&gt;"",
         "children_school"=&gt;"",
         "grade_year"=&gt;"",
         "type"=&gt;"Individual"}}},
   "commit"=&gt;"Next",
   "action"=&gt;"update_children",
   "controller"=&gt;"clients",
   "id"=&gt;"1010"}
  </code></pre>