與軌道3 +設計,我希望用戶能夠更改他們的密碼:色器件,試圖更改密碼時警告:不能大規模指派保護的屬性:current_password
這裏是日誌輸出:
Started POST "/settings/password/update" for 127.0.0.1 at 2011-08-11 11:37:05 -0700
Processing by SettingsController#password_update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"QBZP/h0Xg1SOBWh0+JwzFRyC8X7pE50mx1CgeS6+iNY=", "user"=>{"current_password"=>"[FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Change my password"}
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
SQL (0.2ms) BEGIN
WARNING: Can't mass-assign protected attributes: current_password
AREL (0.7ms) UPDATE "users" SET "encrypted_password" = '$2a$10$cjq9eWB41aqeukarMzyciO4adXB3g.gCSwP6OouV0HT9HZI3IVIa6', "updated_at" = '2011-08-11 18:37:06.326258' WHERE "users"."id" = 3
[paperclip] Saving attachments.
SQL (25.7ms) COMMIT
Redirected to http://localhost:3000/settings/account
Completed 302 Found in 556ms
這裏是password_update控制器方法:
def password_update
@user = current_user
if @user.update_attributes(params[:user])
flash[:notice] = 'Password Updated'
redirect_to '/settings/account'
else
flash[:notice] = 'Error'
redirect_to '/settings/password'
end
end
任何想法,爲什麼發生這種情況?我不是想設置current_password,但根據設計你需要通過它來更新密碼,對吧?謝謝
奇怪的是它正在更新密碼,但後來出來後簽約用戶? – AnApprentice