title: Rails 4 & Devise - User's name is not added to database when new user created
body: <p>I'm new to the Ruby on Rails environment and most problems I've been able to solve, but I haven't been able to find a solution to this problem yet. </p>
  
  <p><strong>To provide context:</strong></p>
  
  <ul>
  <li>Using rails (4.0.0)</li>
  <li>Using warden (1.2.3)</li>
  <li>Using devise (3.0.0)</li>
  <li>Using rolify (3.2.0)</li>
  <li>Using cancan (1.6.10)</li>
  </ul>
  
  <p><strong>My Problem</strong></p>
  
  <p>When I sign_up a new user with <strong>Devise's</strong> registration. The :name field is not being added to the database. <em>See server output</em></p>
  
  <p><strong>User model</strong> (app/models/user.rb)</p>
  
  <p>:name is included in attr_accessible.</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    rolify
    # Include default devise modules. Others available are:
    # :token_authenticatable, :confirmable,
    # :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
  
    # Setup accessible (or protected) attributes for your model
    attr_accessible :role_ids, :as =&gt; :admin
    attr_accessible :name, :email, :password, :password_confirmation, :remember_me
  
  end
  </code></pre>
  
  <p><strong>User controller</strong> (app/controllers/users_controller.rb). </p>
  
  <p>I've added the params whitelist in order to keep with Rails 4, but this didn't solve the problem.</p>
  
  <pre><code>class UsersController &lt; ApplicationController
    before_filter :authenticate_user!
  
    def index
      authorize! :index, @user, :message =&gt; 'Not authorized as an administrator.'
      @users = User.all
    end
  
    def show
      @user = User.find(params[:id])
    end
  
    def update
      authorize! :update, @user, :message =&gt; 'Not authorized as an administrator.'
      @user = User.find(params[:id])
      if @user.update_attributes(params[:user], :as =&gt; :admin)
        redirect_to users_path, :notice =&gt; "User updated."
      else
        redirect_to users_path, :alert =&gt; "Unable to update user."
      end
    end
  
    def destroy
      authorize! :destroy, @user, :message =&gt; 'Not authorized as an administrator.'
      user = User.find(params[:id])
      unless user == current_user
        user.destroy
        redirect_to users_path, :notice =&gt; "User deleted."
      else
        redirect_to users_path, :notice =&gt; "Can't delete yourself."
      end
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_user
        @user = User.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def user_params
        params.require(:user).permit(:name, :email, :password, :password_confirmation, :remember_me)
      end
  end
  </code></pre>
  
  <p><strong>Devise's new registration view</strong> (app/views/devise/registrations/new.html.erb)</p>
  
  <pre><code>&lt;h2&gt;Sign up&lt;/h2&gt;
  &lt;%= simple_form_for(resource, :as =&gt; resource_name, :url =&gt; registration_path(resource_name), :html =&gt; {:class =&gt; 'form-vertical' }) do |f| %&gt;
    &lt;%= f.error_notification %&gt;
    &lt;%= display_base_errors resource %&gt;
    &lt;%= f.input :name, :autofocus =&gt; true %&gt;
    &lt;%= f.input :email, :required =&gt; true %&gt;
    &lt;%= f.input :password, :required =&gt; true %&gt;
    &lt;%= f.input :password_confirmation, :required =&gt; true %&gt;
    &lt;%= f.button :submit, 'Sign up', :class =&gt; 'btn-primary' %&gt;
  &lt;% end %&gt;
  &lt;%= render "devise/shared/links" %&gt;
  </code></pre>
  
  <p><strong>Application controller</strong> (app/controllers/application_controller.rb)</p>
  
  <p>I've followed the instructions with regard to strong parameters, and have included the lazy man's approach from <a href="https://github.com/plataformatec/devise/tree/rails4#strong-parameters">Devise</a></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_filter :configure_permitted_parameters, if: :devise_controller?
  
    rescue_from CanCan::AccessDenied do |exception|
      redirect_to root_path, :alert =&gt; exception.message
    end
  
    protected
  
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:name, :email) }
    end
  end
  </code></pre>
  
  <p><strong>The server output when creating a new user.</strong></p>
  
  <pre><code>Started POST "/users" for 127.0.0.1 at 2013-07-16 15:31:20 +1000
  Processing by Devise::RegistrationsController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"TYp9xOgtdKJI62rUddU7EE1C7FDF5qnmWgGENluzaWk=", "user"=&gt;{"name"=&gt;"John Smith", "email"=&gt;"john.smith@example.com", "password"=&gt;"[FILTERED]", "password_confirmation"=&gt;"[FILTERED]"}, "commit"=&gt;"Sign up"}
  Unpermitted parameters: name
     (0.1ms)  begin transaction
    User Exists (0.1ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = 'john.smith@example.com' LIMIT 1
  Binary data inserted for `string` type on column `encrypted_password`
    SQL (0.3ms)  INSERT INTO "users" ("created_at", "email", "encrypted_password", "updated_at") VALUES (?, ?, ?, ?)  [["created_at", Tue, 16 Jul 2013 05:31:20 UTC +00:00], ["email", "john.smith@example.com"], ["encrypted_password", "$2a$10$kMfZLiBm6md0zoWXd0esjO/IRHBC72444ABDKcXVhPa6mCco9pIJu"], ["updated_at", Tue, 16 Jul 2013 05:31:20 UTC +00:00]]
     (17.0ms)  commit transaction
     (0.1ms)  begin transaction
  Binary data inserted for `string` type on column `last_sign_in_ip`
  Binary data inserted for `string` type on column `current_sign_in_ip`
    SQL (0.4ms)  UPDATE "users" SET "last_sign_in_at" = ?, "current_sign_in_at" = ?, "last_sign_in_ip" = ?, "current_sign_in_ip" = ?, "sign_in_count" = ?, "updated_at" = ? WHERE "users"."id" = 3  [["last_sign_in_at", Tue, 16 Jul 2013 05:31:20 UTC +00:00], ["current_sign_in_at", Tue, 16 Jul 2013 05:31:20 UTC +00:00], ["last_sign_in_ip", "127.0.0.1"], ["current_sign_in_ip", "127.0.0.1"], ["sign_in_count", 1], ["updated_at", Tue, 16 Jul 2013 05:31:20 UTC +00:00]]
     (1.1ms)  commit transaction
  Redirected to http://0.0.0.0:3000/
  Completed 302 Found in 94ms (ActiveRecord: 19.0ms)
  </code></pre>
  
  <p><strong>My Conclusion</strong></p>
  
  <p>After all this I believe the problem lies in <strong>Devise's</strong> registration_controller, but I'm not exactly sure how to go about accessing the controller and rectifying this, or if this is where the problem actually is. I'm hoping it is something simple and I've just overlooked it.</p>
  
  <p>If anyone has run into this problem or can shine some light on the situation, it would be greatly appreciated.</p>
  
  <p>Cheers.</p>