I followed this tutorial verbatim:
https://github.com/plataformatec/devise/wiki/How-To:-Email-only-sign-up
But when the user clicks the confirm link, it doesn't show the screen where they set a password, yet it sets them to confirmed. I have looked at the logs and it makes the request to the confirmations controller but doesn't show the view - just processes the token and redirects to logged-in root.
Started GET "/users/confirmation?confirmation_token=gs5NCZTu3hSJeWqCGDr6" for 127.0.0.1 at 2013-08-18 00:15:06 +0100
Processing by Devise::ConfirmationsController#show as HTML
Parameters: {"confirmation_token"=>"gs5NCZTu3hSJeWqCGDr6"}
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'gs5NCZTu3hSJeWqCGDr6' LIMIT 1[0m
[1m[35m (0.1ms)[0m BEGIN
[1m[36m (0.5ms)[0m [1mUPDATE "users" SET "confirmation_token" = NULL, "confirmed_at" = '2013-08-17 23:15:06.840455', "updated_at" = '2013-08-17 23:15:06.841240' WHERE "users"."id" = 4[0m
[1m[35m (0.4ms)[0m COMMIT
[1m[36m (0.1ms)[0m [1mBEGIN[0m
[1m[35m (0.3ms)[0m UPDATE "users" SET "last_sign_in_at" = '2013-08-17 23:15:06.843987', "current_sign_in_at" = '2013-08-17 23:15:06.843987', "last_sign_in_ip" = '127.0.0.1', "current_sign_in_ip" = '127.0.0.1', "sign_in_count" = 1, "updated_at" = '2013-08-17 23:15:06.844495' WHERE "users"."id" = 4
[1m[36m (0.3ms)[0m [1mCOMMIT[0m
Redirected to http://0.0.0.0:5000/
My routes (as instructed) are:
devise_for :users, :controllers => { :registrations => "registrations", :confirmations => 'confirmations' }
devise_scope :user do
put "/confirm" => "confirmations#confirm"
end
And I have a show.html.erb in app/views/devise/confirmations AND in app/views/confirmations just in case as their instructions (misleadingly) state such.
I think it might have something to do with this controller they have you make:
class ConfirmationsController < Devise::ConfirmationsController
def show
self.resource = resource_class.find_by_confirmation_token(params[:confirmation_token]) if params[:confirmation_token].present?
super if resource.nil? or resource.confirmed?
end
Is it supposed to render the view here? Because the super class of this never calls show either:
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource) if Devise.allow_insecure_sign_in_after_confirmation
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
end
end
Edit: I've changed the code in my confirmations controller to purely render :action => "show"
to make sure it's using my controller but it hasn't had any effect. I double checked with rake routes
and it seems right yet isn't overriding it seems:
POST /users/confirmation(.:format) confirmations#create
GET /users/confirmation/new(.:format) confirmations#new
GET /users/confirmation(.:format) confirmations#show
confirmation PUT /confirmation(.:format) confirmations#confirm