ruby on rails - How to update associated models in gem "devise" account_update action -


i'm new in ruby on rails

i use gem "devise" authentication users , have trouble update assosiated models in account update action. @ account update, keys 'user_id' in assosiated records set nil

database queries occurs:

update "user_information" set "user_id" = ? "user_information"."user_id" = ?  [["user_id", nil], ["user_id", 1]] update "user_settings" set "user_id" = ? "user_settings"."user_id" = ?  [["user_id", nil], ["user_id", 1]] 

ie request reset key user_id nil in associated models. doing wrong?

my code:

migrations

create_table(:users) |t|   t.string :email,              null: false, default: ""   t.string :encrypted_password, null: false, default: ""   # etc end  create_table :user_settings, :id => false |t|   t.references :user, null: false, index: true, unique: true   # etc end  create_table :user_information, :id => :user_id |t|   t.references :user, null: false, index: true, unique: true   # etc end 

user model

class user < activerecord::base   has_one :setting, :class_name => 'user::setting', inverse_of: :user   has_one :information, :class_name => 'user::information', inverse_of: :user    accepts_nested_attributes_for :setting   accepts_nested_attributes_for :information'    # devise end 

registrations controller

class users::devise::registrationscontroller < devise::registrationscontroller   before_filter :configure_permitted_parameters    protected    def configure_permitted_parameters     devise_parameter_sanitizer.for(:account_update) |u|       u.permit(:name, :email, :password, :password_confirmation, :current_password,            information_attributes: [:name, :contacts], setting_attributes: [:monetization])         # etc     end   end    def build_resource(hash=nil)     super     self.resource.build_setting     self.resource.build_information if hash.empty?   end end 


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -