Reputation: 194
I am currently working on setting up a project based around the tutorial on Devise labeled Email only signup and seem to be encountering one specific error which I cannot work around. I have got the plugin to do everything except step 3 where it fails to find the custom method I have added called confirm
. I have already told Devise to use
devise_for :users, :controllers => {:confirmations => 'confirmations'}
for my users plugin, but it is ignoring my controller.
I have a controller called confirmations_controller.rb and it contains the following code:
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
The exact error is:
undefined method `confirmed?' for #<User:0x425f130>
I am using rails version 3.2.9 and devise version 2.2.1
I am just learning rails and ruby so I really hope someone can help me with this.
Upvotes: 0
Views: 490
Reputation: 13057
The error message is about the confirmed?
method being not defined. The custom method you added is confirm
The confirmed?
method is added by the confirmable
module of device
As Jesse mentioned in the comment above, enable the 'confirmable' module for the User class.
Example User class:
class User < ActiveRecord::Base
devise ..., :confirmable, ...
...
end
Upvotes: 2