1
我在用戶驗證的Rails應用程序中使用Devise。我已經創建了註冊和會話控制器,但是現在我需要一個控制器來模擬來自腳手架的def update
。有沒有辦法訪問Devise用來更新用戶的控制器?設計的更新控制器
我在用戶驗證的Rails應用程序中使用Devise。我已經創建了註冊和會話控制器,但是現在我需要一個控制器來模擬來自腳手架的def update
。有沒有辦法訪問Devise用來更新用戶的控制器?設計的更新控制器
是的,你也可以繼承使用色器件編輯用戶,做任何你想要的更新動作registrations_controller,這是與它的默認更新動作子類控制器:
class Users::RegistrationsController < Devise::RegistrationsController
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
if resource.update_with_password(params[resource_name])
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords(resource)
respond_with_navigational(resource){ render_with_scope :edit }
end
end
end
我認爲就是圖謀在註冊控制器中執行用戶更新 – binarycode