所以这看起来很简单,我有一个如下所示的控制器操作:
class Admin::UsersController < Admin::BaseController
...
def update_password
@user = User.find(params[:user][:id])
@user.password = params[:user][:password]
if @user.save!
Notifier.admin_password_change(@user).deliver
flash[:success] = "Password Changed!"
redirect_to edit_admin_user_path(@user)
else
render "edit"
end
end
end
它似乎从来没有工作过。我需要在这里更高级的东西吗?这是我在 rails 控制台中看到的内容:
Started PUT "/admin/users/update_password" for 127.0.0.1 at 2013-07-15 10:01:50 -0600
Processing by Admin::UsersController#update_password as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"ipedx2MJDZTQct6I4FUObrzDpMNl3pQWNVr9Ez7bDVc=", "user"=>{"id"=>"226", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Change Password"}
(6.8ms) ALTER SESSION SET EDITION = EPACT_REDESIGN
User Load (8.4ms) SELECT "CRED_APP_USERS".* FROM "CRED_APP_USERS" WHERE "CRED_APP_USERS"."ID_NUMBER" = 10040 AND ROWNUM <= 1
CodeModel Load (9.1ms) SELECT "CRED_CODES".* FROM "CRED_CODES" WHERE (table_name = 'CRED_VEHICLES' OR table_name = 'CRED_FLEET')
User Load (3.6ms) SELECT "CRED_APP_USERS".* FROM "CRED_APP_USERS" WHERE "CRED_APP_USERS"."ID_NUMBER" = :a1 AND ROWNUM <= 1 [["id_number", "226"]]
(3.3ms) UPDATE "CRED_APP_USERS" SET "ENCRYPTED_PASSWORD" = 'ENCRYPTED PASSWORD STRING', "MODIFY_DT" = TO_DATE('2013-07-15 16:01:50','YYYY-MM-DD HH24:MI:SS') WHERE "CRED_APP_USERS"."ID_NUMBER" = 226
Rendered notifier/admin_password_change.erb (0.1ms)
Sent mail to random@person.com (22ms)
...
我在这里做错了什么?电子邮件在控制台中打印出来,:success
屏幕顶部出现闪光灯,但密码没有更改。