ruby on rails - Devise error: Unpermitted parameters -


how register user username devise? have far throws me following error:

error:  processing devise::sessionscontroller#new html   parameters: {"utf8"=>"✓", "authenticity_token"=>"oa1sf2dgku/vpgoai5ocnm8e5gnkuswxx9kkptlfuzmuwto40cfoseziyq3eqz71btw9r3afohpbd5ezcavcga==", "user"=>{"username"=>"mcarpintini", "email"=>"carpintinimatias@gmail.com", "password"=>"[filtered]", "password_confirmation"=>"[filtered]"}, "commit"=>"register"} unpermitted parameters: :username, :password_confirmation 

registration form

.ui.middle.aligned.center.aligned.grid   .column     =form_for(resource, html: {class:"ui large form"}, as: resource_name,url: session_path(resource_name)) |f|       .ui.stacked.segment         .field           .ui.left.icon.input             %i{class:"user icon"}             =f.text_field :username, placeholder: "username"         .field           .ui.left.icon.input             %i{class:"mail icon"}             =f.email_field :email, placeholder:"email"         .field           .ui.left.icon.input             %i{class:"lock icon"}             =f.password_field :password, placeholder:"password"          .field           .ui.left.icon.input             %i{class:"repeat icon"}             =f.password_field :password_confirmation, placeholder:"password confirmation"          =f.submit "register", class:"ui fluid large teal submit button"       .ui.error.message     .ui.message       have account?       =link_to "login", new_user_session_path 

user model

class user < applicationrecord   # include default devise modules. others available are:   # :confirmable, :lockable, :timeoutable , :omniauthable    devise :database_authenticatable, :registerable,          :recoverable, :rememberable, :trackable, :validatable  end 

user table structure.

create_table "users", force: :cascade |t|     t.string "username", default: "", null: false     t.string "avatar_file_name", default: "", null: false     t.string "avatar_content_type", default: "", null: false     t.integer "avatar_file_size", null: false     t.datetime "avatar_updated_at", null: false     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.integer "sign_in_count", default: 0, null: false     t.datetime "current_sign_in_at"     t.datetime "last_sign_in_at"     t.string "current_sign_in_ip"     t.string "last_sign_in_ip"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     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 

you need permit additional parameters via strong parameters. since have custom parameter username defined, have permit same:

before_action :configure_permitted_parameters, if: :devise_controller?  def configure_permitted_parameters   devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :password_confirmation]) end 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -