title: Enabling Bcrypt on Rails 5
body: <p>I'm starting a new app on Rails 5.0.0 and trying to use bcrypt. I've followed the directions on the bcrypt repo but something is missing as I'm getting <code>ActiveModel::ForbiddenAttributesError</code></p>
  
  <p>Here is the <code>user.rb</code>:</p>
  
  <pre><code>require 'bcrypt'
  
  class User &lt; ActiveRecord::Base
   include BCrypt
  
   def password
      @password ||= Password.new(password_hash)
   end
  
   def password=(new_password)
      @password = Password.create(new_password)
      self.password_hash = @password
   end
  
   has_many :trips
  end
  </code></pre>
  
  <p><strong>Migration details:</strong></p>
  
  <pre><code>class CreateUsers &lt; ActiveRecord::Migration[5.0]
    def change
      create_table :users do |t|
          t.string  :first_name,    null: false
          t.string  :last_name,     null: false
          t.string  :email,         null: false
          t.string  :password_hash, null: false
  
          t.timestamps
      end
    end
  end
  </code></pre>
  
  <p><strong>users_controller.rb</strong>:</p>
  
  <pre><code>class UsersController &lt; ApplicationController
  
    def create
      user = User.new(params[:user])
      user.password = params[:password]
      user.save!
    end
  
    def new
     @user = User.new
    end
  
    private
  
    def user_params
     params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation)
    end
  end
  </code></pre>
  
  <p><strong>Here is the beginning of the stack trace:</strong></p>
  
  <pre><code>Started POST "/users" for ::1 at 2016-09-19 16:44:20 -0700
  Processing by UsersController#create as HTML
    Parameters: {"utf8"=&gt;"✓",     "authenticity_token"=&gt;"GWJXon2Y914Y7m2NGPAj8wz+9O6EBO1OnrIcBBRis/ATMkaGMCRh6uE4PAxJOIE7mVrornt5PqOvxBjoOBo9ag==", "user"=&gt;{"first_name"=&gt;"test", "last_name"=&gt;"test2", "email"=&gt;"123@gmail.com", "password"=&gt;"[FILTERED]", "password_confirmation"=&gt;"[FILTERED]"}, "commit"=&gt;"Create User"}
  Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms)
  
  
  ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError):
  
  app/controllers/users_controller.rb:4:in `create'
    Rendering /Users/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
  </code></pre>