title: Adding Fields To Devise Sign Up Using Rails 4
body: <p>To start off, I'm new to rails, so I'm still getting the hang of things. </p>
  
  <p>I'm attempting to add two fields to the Devise sign up page, a first name field and a last name field. I've gone ahead and changed the view and the controller in order to attempt this. They look like this:</p>
  
  <p>Controller:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
  
    before_action :configure_devise_permitted_parameters, if: :devise_controller?
  
    protected
  
    def configure_devise_permitted_parameters
      registration_params = [:firstName, :lastName, :email, :password, :password_confirmation]
  
      if params[:action] == 'update'
        devise_parameter_sanitizer.for(:account_update) { 
          |u| u.permit(registration_params &lt;&lt; :current_password)
      }
      elsif params[:action] == 'create'
        devise_parameter_sanitizer.for(:sign_up) { 
          |u| u.permit(registration_params) 
        }
      end
    end
  end
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;h2&gt;Sign up&lt;/h2&gt;
  
  &lt;%= form_for(resource, :as =&gt; resource_name, :url =&gt; registration_path(resource_name)) do |f| %&gt;
    &lt;%= devise_error_messages! %&gt;
  
    &lt;div&gt;&lt;%= f.label :email %&gt;&lt;br /&gt;
    &lt;%= f.email_field :email, :autofocus =&gt; true %&gt;&lt;/div&gt;
  
    &lt;div&gt;&lt;%= f.label :password %&gt;&lt;br /&gt;
    &lt;%= f.password_field :password %&gt;&lt;/div&gt;
  
    &lt;div&gt;&lt;%= f.label :password_confirmation %&gt;&lt;br /&gt;
    &lt;%= f.password_field :password_confirmation %&gt;&lt;/div&gt;
  
    &lt;div&gt;&lt;%= f.label :firstName %&gt;&lt;br /&gt;
    &lt;%= f.fName_field :firstName %&gt;&lt;/div&gt;
  
    &lt;div&gt;&lt;%= f.label :lastName %&gt;&lt;br /&gt;
    &lt;%= f.lName_field :lastName %&gt;&lt;/div&gt;
  
    &lt;div&gt;&lt;%= f.submit "Sign up" %&gt;&lt;/div&gt;
  &lt;% end %&gt;
  &lt;%= render "devise/shared/links" %&gt;
  </code></pre>
  
  <p>However, I get this error when I go to view the page:</p>
  
  <pre><code>undefined method `fName_field' for #&lt;ActionView::Helpers::FormBuilder:0x00000003c89940&gt;
  </code></pre>
  
  <p>Where must I define those methods? or are they automatically defined somewhere else?</p>
  
  <p>Thanks for any help.</p>