我目前正在設置一個基於tutorial on Devise labeled Email only signup的項目,並且似乎遇到了一個我無法解決的特定錯誤。我已經得到插件來執行除第3步以外的任何操作,它無法找到我添加的名爲confirm
的自定義方法。我已經告訴設計使用在Devise和Rails中創建電子郵件註冊時出現問題
devise_for :users, :controllers => {:confirmations => 'confirmations'}
爲我的用戶插件,但它忽略了我的控制器。
我有一個控制器稱爲confirmations_controller.rb,它包含以下代碼:
class ConfirmationsController < Devise::ConfirmationsController
def show
self.resource = resource_class.find_by_confirmation_token(params[:confirmation_token])
super if resource.confirmed?
end
def confirm
self.resource = resource_class.find_by_confirmation_token(params[resource_name][:confirmation_token])
if resource.update_attributes(params[resource_name].except(:confirmation_token)) && resource.password_match?
self.resource = resource_class.confirm_by_token(params[resource_name][:confirmation_token])
set_flash_message :notice, :confirmed
sign_in_and_redirect(resource_name, resource)
else
render :action => "show"
end
end
確切的錯誤是:
undefined method `confirmed?' for #<User:0x425f130>
我使用軌道版本3.2.9,並制定2.2版本.1
我只是學習rails和ruby,所以我真的希望有人能幫助我。
你加:可確定用戶類? –