ruby on rails - Why won't devise update an attribute in my DB? -
We have copied / pasted the Device Registration Controller and there are some ways to improve things. General
Update method looks like this:
def update self.resource = resource_class.to_adapter.get (send ( "current _ # {RESOURCE_NAME}"). to_key) prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to (? unconfirmed_email) AP that block_given resource_updated = resource.update_attributes (account_update_params) produce resources account_update_params? If resource_updated if is_flashing_format? Flash_key = update_needs_confirmation? (Resource, prev_unconfirmed_email)? : Update_needs_confirmation: Update set_flash_message: notice, sign_in RESOURCE_NAME, processing, bypass flash_key inter really respond_with resources, location: after_update_path_for (resources) and clean_up_passwords resource respond_with processing end end
I put AP Khata_apdet_prm it To make sure that I'm getting all the right stuff before the update:
{"email" => "Email@address.com", "First_name" = & gt; "Foo", "LastName" = & gt; "Bar", "user-type" = & gt; "1", "company" = & gt; "Company", "phone" = & gt; "555-555-5555", "Temp_Unets" = & gt; "C", "volume_measure" = & gt; "0", "address1" = & gt; "1234 LN anywhere", "address_2" => "", "City" = & gt; "Somewhere", "province" = & gt; "CA", "Mail" = & gt; "90210", "country_id" => "201"}
Yes, they all are there
Here's the issue: .. Temp_units and volume_measure never been updated
Model:
attr_accessible: Email ,: Password: password_confirmation ,: remember_me ,: temp_units ,: first_name ,: last_name ,: company, : ADDRESS_1 ,: address_2 ,: city ,: province ,: mail: phone ,: Desh_aidi ,: Volum_mejr ,: user_type
they are accessible - and update all other parameters Okay. Only these two are not being touched.
Why
It is not turned on Trust all.
Someone else had examined this good investigation:
# It is used after user build. # If the user is a U.S.A. , Then it will set the user's # default locale in the inferior measurement units. DEF if [201, 200] .include? (Self.country_id) self.temp_units = "f" self.volume_measure = User :: VOLUME_MEASURE_GALLONS rest self.temp_units = "C" self.volume_measure = User :: VOLUME_MEASURE_LITERS finally end set_locale
And nested somewhere near the top of the model:
before_save: set_locale changed from # after_save.
...
Comments
Post a Comment