Devise 3.2.2를 사용 중입니다. 그리고 확인을 켰어.확인 토큰이 잘못되었습니다.
SQL을 사용하면 사용자 테이블에 성공적인 토큰이 만들어 졌음을 알 수 있습니다.
토큰이 생성 된 이메일 링크에 있습니다. 그러나 그것을 클릭하면 Confirmation token is invalid error가 발생합니다. 이미 사용자 이름이나 전자 메일을 사용하여 로그인 할 수 있도록 작업 코드가 있지만 충돌하지 않기를 바랍니다.
ERB :
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
사용자 모델 :
이class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
# Virtual attribute for authenticating by either username or email
# This is in addition to a real persisted field like 'username'
attr_accessor :login
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :approved, :role, :username, :userfriendlyname, :persona, :public, :login, :active, :confirmation_token, :confirmed_at, :confirmation_sent_at
# attr_accessible :title, :body
# MTM 06/21/2014 to allow for login with username or email
def self.find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
else
where(conditions).first
end
end
# MTM 06/23/2014 to allow for login with username or email
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
else
where(conditions).first
end
end
end