Tuesday 15 September 2015

ruby on rails - Why does Devise keep asking me that the name can't be blank? -


I am new to rail, and I am working with Devise. The problem I am experiencing is that my form name column is not updating when my user is signing up. I have the name attribute in the data table, but I can not change it by using a form for registration.

  & lt; H2 & gt; Sign up & lt; / H2 & gt; & Lt;% = form_for (resource, as: = & gt; processing_name ,: url = & gt; registration_path (resource_name)) f | F | & Gt%; & Lt;% = devise_error_messages! & Gt%; & Lt; Div & gt; & Lt;% = f.label: name% & gt; & Lt; Br / & gt; & Lt;% = f.text_field: name ,: autofocus = & gt; True% & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt;% = f.label: email% & gt; & Lt; Br / & gt; & Lt;% = f.email_field: email% & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt;% = f.label: Password% & gt; & Lt; Br / & gt; & Lt;% = f.password_field: Password% & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt;% = f.label: password_confirmation% & gt; & Lt; Br / & gt; & Lt;% = f.password_field: password_confirmation% & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt;% = f.submit "Sign Up"% & gt; & Lt; / Div & gt; & Lt;% end% & gt; & Lt;% = Render "devise / shared / links"% & gt; Class user & lt; ActiveRecord :: Base # include default develop modules Others are: #: token_authenticatable ,: encryptable,:, confirmable :, lockable: timeoutable and: omniauthable will :, database_authenticatable :, registerable :, recovery :, Rememberable: trackable, validateable has_many: terminated   

scheme .bb

  ActiveRecord :: Schema.define (version: 20130622203624) Create_table " Post ", force: true do | T | T.integer "user_id" t.text "description" t.integer "comments_id" t.datetime "created_at" t.datetime "updated_at" t.string "title" end create_table "users", force: true do | T | "", Null: false Tkstring "Encrypted_password" default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" "remember_created_at" T t.datetime "email", default t.string. Integer "SIGN_IN_COUNT", default: 0 t.datetime "current_sign_in_at" "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime t.datetime "updated_at" t.string "name" , null: false end add_index "them", [ "email"] name: "Index_users_on_email" unique: while true, use: BTREE add_index "them", [ "Reset_password_token"] name: "Index_users_on_reset_password_token" Unique: true, use :: btree create_table "idea", force: true do | T | T.string "email", default: "", empty: incorrect t.string "encrypted_password", range: 128, default: "", empty: incorrect t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime " remember_created_at "t.integer" SIGN_IN_COUNT ", default: 0 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 "t.datetime" updated_at "end add_index "ideas", [ "email"] name: "Index_views_on_email" unique: while true, use of the BTREE add_index "scene", [ "Reset_password_token"] name: "Index_views_on_reset_password_token" unique: true, Using: BTREE End    

if You need strong parameter rail are using 4. If you need to apply extra parameters to plan, you can either create an additional 1-1 profile for users and store them there (better app in the long run or if you have more users Data) and I personally feel it is very easy to include my user data in the user's user table

Alternatively, you can do the following if you are using one or two attributes.

For your Name Parameter Scheme, do this in your ApplicationController code.

  class ApplicationController & lt; ActionController :: Before use_filters: configure_permitted_parameters, if: devise_controller? Protect def def_permitted_parameters devise_parameter_sanitizer.for (: sign_up) & lt; & Lt; : End of Name End   

See more on this.

No comments:

Post a Comment