0
我們複製/粘貼Devise註冊控制器及其一些方法來調整事物。正常。爲什麼不會在我的數據庫中設計更新屬性?
update方法是這樣的:
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 account_update_params
resource_updated = resource.update_attributes(account_update_params)
yield resource if block_given?
if resource_updated
if is_flashing_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, bypass: true
respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
respond_with resource
end
end
我把AP在那裏account_update_params,以確保我得到了所有正確的東西更新之前:
{
"email" => "[email protected]",
"first_name" => "Foo",
"last_name" => "Bar",
"user_type" => "1",
"company" => "Company",
"phone" => "555-555-5555",
"temp_units" => "c",
"volume_measure" => "0",
"address_1" => "1234 Anywhere Ln",
"address_2" => "",
"city" => "Somewhere",
"province" => "CA",
"postal" => "90210",
"country_id" => "201"
}
是啊,他們」所有在那裏。
以下是問題:temp_units和volume_measure從不更新。
型號:
attr_accessible :email,
:password,
:password_confirmation,
:remember_me,
:temp_units,
:first_name,
:last_name,
:company,
:address_1,
:address_2,
:city,
:province,
:postal,
:phone,
:country_id,
:volume_measure,
:user_type
他們訪問 - 和所有其他PARAMS得到更新就好了。只有這兩個沒有被觸及。
爲什麼
你有什麼在模型中驗證可能會阻止更新? – mmichael 2014-10-17 18:42:45