当用户编辑他的页面时,我需要调用函数。
这是我的 settings_controller.rb:
class SettingsController < ApplicationController
def update
@user = User.find(current_user.id)
email_changed = @user.email != params[:user][:email]
password_changed = !params[:user][:password].empty?
successfully_updated = if email_changed or password_changed
@user.update_with_password(params[:user])
else
@user.update_without_password(params[:user])
end
if successfully_updated
# Sign in the user bypassing validation in case his password changed
sign_in @user, :bypass => true
//need to call action here
else
render "edit"
end
end
end
如果更新成功,我需要重定向用户。
在我的 routes.rb 中:
devise_for :users, :controllers => {:registrations => 'registrations', :settings => 'settings'}
还是我做错了什么?