【问题标题】:Rails Devise - confirmable bugs ? Issue with DeviseRails 设计 - 可确认的错误?设计问题
【发布时间】:2014-02-11 04:01:46
【问题描述】:

我正在使用 Rails 4.0.2 和 Devise 3.2.2 来处理用户注册/身份验证。我已启用:confirmable

当我进入根目录时,有注册字段,注册后,它不会重定向到我设置的页面,而是停留在同一页面,并显示以下错误消息, 也没有发送确认邮件。

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

当我转到Rails console 时,输入User.all,该用户已在那里创建。

看起来 Devise 在注册两次时正在创建用户。我不确定 Devise 是否存在错误,或者这是我的一部分。请帮忙。

谢谢!

以下是我的代码:

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

【问题讨论】:

标签: ruby-on-rails ruby devise ruby-on-rails-4


【解决方案1】:

您的'pages/success' 缺少斜线。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    • 2012-07-16
    • 1970-01-01
    • 2019-01-22
    • 2012-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多