Reputation: 1
I'm trying to add some customs parameters to a devise class. I configured registrations_controller
with the method:
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :phone, :photo])
end
and the line: before_action :configure_sign_up_params, only: [:create]
def create
logger.debug "#{params[:user].inspect}
super
end
When i create a user, the response is:
Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"name"=>"Eduardo", "phone"=>"1111111111", "email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
web-1 | #<ActionController::Parameters {"name"=>"Eduardo", "phone"=>"11997828098", "email"=>"[email protected]", "password"=>"123456", "password_confirmation"=>"123456"} permitted: false>
But the insert in db is:
INSERT INTO "users" ("email", "encrypted_password") VALUES ($1, $2) RETURNING "id" [["email", "[email protected]"], ["encrypted_password", "$2a$12$0fak5E1ODq0NWokphw0gYebkTSaYcjO6vjRe3D8ICYZtisIrNQq7O"]]
Why are the custom parameters not being inserted?
Schema:
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.string "name"
t.string "phone"
t.string "photo"
t.string "role"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Routes:
devise_for :users, controllers: {
registrations: 'users/registrations',
sessions: 'users/sessions'
}
I tried to recreate Users table, reinstall and configure devise again, but does not worked. I need that the parameters be in the database.
Upvotes: 0
Views: 74