3

Cant Confirm email, with devise.

route.rb

  devise_for :users, :controllers => { :sessions => "users/sessions" ,:omniauth_callbacks => "users/omniauth_callbacks" } do
    post   "users/confirmation",          :to => "devise/confirmations#create"
    get    "users/confirmation/new",      :to => "devise/confirmations#new", :as => "new_confirmation"
    get    "users/confirmation",          :to => "devise/confirmations#show"
  end
  resources :pensioners #, :only => [:index, :destroy, :new]
  resources :users #, :only => [:index, :destroy, :new]

heroku run rake routes

                                                             ....
   user_confirmation POST   /users/confirmation(.:format) devise/confirmations#create

   new_user_confirmation GET    /users/confirmation/new(.:format) devise/confirmations#new

                  GET    /users/confirmation(.:format)          devise/confirmations#show

                                                              ....

But when I make request

    GET /users/confirmation?confirmation_token=BeELxDDq9sxpseLh8Rdn 

I get 404 error

  The page you were looking for doesn't exist.
  You may have mistyped the address or the page may have moved.

Where am I wrong at?

Model:

 class User < ActiveRecord::Base
      devise .... , :confirmable

Migration:

class AddConfirmableToUsers < ActiveRecord::Migration
  def up
   add_column :users, :confirmation_token, :string
   add_column :users, :confirmed_at, :datetime
   add_column :users, :confirmation_sent_at, :datetime
   add_index :users, :confirmation_token, :unique => true
   User.update_all(:confirmed_at => Time.now)
  end
  ....
Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
Timopheym
  • 363
  • 3
  • 15

2 Answers2

5

Kinda late, but anyway. Try to use a PATCH instead of GET. Your routes.rb should have a route like

patch '/user/confirmation' => 'user/confirmations#update', :via => :patch, :as => :update_user_confirmation
Danny Ocean
  • 1,081
  • 2
  • 14
  • 30
  • 1
    @issy sorry for late response. Here it is if you still need it: `patch '/user/confirmation' => 'user/confirmations#update', :via => :patch, :as => :update_user_confirmation` – Danny Ocean Feb 19 '15 at 12:38
  • I couldn't understand how to apply that fix, can you elaborate? – Ferit May 27 '17 at 13:55
  • @Saibot I've updated an answer but don't know what else can I say. I haven't been used devise for a long long time now. – Danny Ocean May 31 '17 at 07:14
  • I'm new to web development, so it was not easy to figure out this fix belongs to routes. :) Found it myself after a couple hours, but thanks anyway. – Ferit May 31 '17 at 07:21
  • 1
    @Saibot glad you figured it out! I believe that self-learning is the most useful. Anyway, have a nice journey :) – Danny Ocean May 31 '17 at 09:18
0

In Rails 4.2.10, with Devise 4.4.3, this worked for me:

devise_for :users, controllers: { registrations: 'registrations',
                                  sessions: 'sessions',
                                  confirmations: 'confirmations' }
devise_scope :user do
  # custom routes...
  get 'confirmation/sent' => 'confirmations#sent'
  patch 'users/confirmation' => 'confirmations#create'
end
Brent
  • 99
  • 7