Jimmy
Jimmy

Reputation: 427

Rails Devise - confirmable bugs ? Issue with Devise

I am using Rails 4.0.2 and Devise 3.2.2 to handle user registration / authentication. I have enabled :confirmable

When I go to root, there is the sign up field, after sign up, instead of redirecting to the page that I've set, it stays at the same page with the below error message, and didn't send the confirmation email either.

2 errors prohibited this user from being saved:
Email has already been taken
Username has already been taken

And when I go to Rails console, type User.all that user is there created.

It looks like Devise is creating the user while sign up twice. I'm not sure whether there are bugs with Devise or it's my part. Please help.

Thanks!

Below are my codes:

registrations_controller.rb:

class RegistrationsController < Devise::RegistrationsController

  def update

  protected


  def after_inactive_sign_up_path_for(resource)
     'pages/success'
 end
end

user.rb :

class User < ActiveRecord::Base

  # Include default devise modules. Others available are:
  #:lockable, :timeoutable and :omniauthable


  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable

  validates :username, :uniqueness => {:case_sensitive => false}

end

Upvotes: 2

Views: 503

Answers (1)

laman
laman

Reputation: 562

Your 'pages/success' is missing a slash.

registrations_controller.rb:

class RegistrationsController < Devise::RegistrationsController

  def update

  protected


  def after_inactive_sign_up_path_for(resource)
     'pages/success'   # should be '/pages/success'
 end
end

Upvotes: 2

Related Questions