create the migration
class
AddFieldsToUsers < ActiveRecord::Migration
def
change
add_column
:users
,
:first_name
,
:string
add_column
:users
,
:last_name
,
:string
end
end
Customizing the RegistrationsController
creating our own registrations controller (which extends Devise) and then customizing these methods as we choose.
class
RegistrationsController < Devise::RegistrationsController
private
def
sign_up_params
params.require(
:user
).permit(
:first_name
,
:last_name
,
:email
,
:password
,
:password_confirmation
)
end
def
account_update_params
params.require(
:user
).permit(
:first_name
,
:last_name
,
:email
,
:password
,
:password_confirmation
,
:current_password
)
end
end
Now we need to tell Devise to use our registrations controller - we can do this in ourconfig/routes.rb file.
devise_for
:users
,
:controllers
=> { registrations:
'registrations'
}
沒有留言:
張貼留言