在 Rails 3 中它工作得很好,但我的新 Rails4 Appp 我不知道问题出在哪里。
设计 GitHub 页面上的指南
我的注册控制器
def update
# required for settings form to submit when password is left blank
if params[:user][:password].blank?
params[:user].delete("password")
params[:user].delete("password_confirmation")
end
@user = User.find(current_user.id)
if @user.update_without_password(devise_parameter_sanitizer.sanitize(:account_update))
set_flash_message :notice, :updated
# Sign in the user bypassing validation in case his password changed
sign_in @user, :bypass => true
redirect_to after_update_path_for(@user)
else
render "edit"
end
end
我的应用程序控制器
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:name, :first_name, :user_name, :email, :password, :password_confirmation, :provider, :uid)
end
devise_parameter_sanitizer.for(:account_update) do |u|
u.permit(:name, :email, :password, :password_confirmation, :first_name, :last_name,
:user_name, :avatar, :profile_cover, :facebook_link,
:twitter_link, :instagram_link, :status)
end
end
我将控制器添加到我的路线
:registrations => "registrations"
我使用以下适当的方法更改了更新调用:
@user.update_without_password(devise_parameter_sanitizer.sanitize(:account_update))
但我得到一个NoMethodError in RegistrationsController#update
错误。