Ruby on rails Deviate已签约但未确认获胜;不显示
我最近使用Desive将confirmable添加到我的rails应用程序中。这一切都很顺利,但是当我创建一个新用户时,我得到了Ruby on rails Deviate已签约但未确认获胜;不显示,ruby-on-rails,devise,devise-confirmable,notice,Ruby On Rails,Devise,Devise Confirmable,Notice,我最近使用Desive将confirmable添加到我的rails应用程序中。这一切都很顺利,但是当我创建一个新用户时,我得到了 signed_up: "Welcome! You have signed up successfully." 而不是 signed_up_but_unconfirmed:"A message with a confirmation link has been sent to your email address. Please follow the link to
signed_up: "Welcome! You have signed up successfully."
而不是
signed_up_but_unconfirmed:"A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
即使他们未经证实。在添加confirmable以更改此设置时,是否需要执行某些操作?谢谢
更新
我正在使用自己的用户控制器,并按如下方式进行路由:
routes.rb
devise_for :users, :controllers => {:registrations => "users"}
devise_scope :user do
get 'users/:id' => 'users#show', as: "user"
end
你可以用这个来确定你的路线
as :user do
patch '/users/confirmation' => 'users/confirmations#update', :via => :patch, :as => :update_user_confirmation
end
并向控制员确认以下信息:
class Users::ConfirmationsController < Devise::ConfirmationsController
skip_before_filter :authenticate_user!
before_action :check_if_current_user
# PUT /resource/confirmation
def update
with_unconfirmed_confirmable do
if @confirmable.has_no_password?
@confirmable.attempt_set_password(params[:user])
if @confirmable.valid? && @confirmable.password_match?
do_confirm
else
do_show
@confirmable.errors.clear #so that we wont render :new
end
else
self.class.add_error_on(self, :email, :password_already_set)
end
end
if !@confirmable.errors.empty?
render 'devise/confirmations/new' #Change this if you don't have the views on default path
end
end
# GET /resource/confirmation?confirmation_token=abcdef
def show
with_unconfirmed_confirmable do
if @confirmable.has_no_password?
do_show
else
do_confirm
end
end
if !@confirmable.errors.empty?
self.resource = @confirmable
render 'devise/confirmations/new' #Change this if you don't have the views on default path
end
end
protected
def with_unconfirmed_confirmable
original_token = params[:confirmation_token]
confirmation_token = Devise.token_generator.digest(User, :confirmation_token, original_token)
@confirmable = User.find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
if !@confirmable.new_record?
@confirmable.only_if_unconfirmed { yield }
end
end
def do_show
@confirmation_token = params[:confirmation_token]
@requires_password = true
self.resource = @confirmable
render 'devise/confirmations/show' #Change this if you don't have the views on default path
end
def do_confirm
@confirmable.confirm!
set_flash_message :notice, :confirmed
sign_in_and_redirect(resource_name, @confirmable)
end
def check_if_current_user
if current_user.present?
render :file => "#{Rails.root.to_s}/public/confirmed.html", :status => :unauthorized
end
end
end
class用户::确认控制器“35;{Rails.root.to_s}/public/confirm.html”,:status=>:unauthorized
终止
终止
终止
希望对您有所帮助。使用Desive有很多不同的版本和方法,因此很难用给定的信息帮助您。例如:您是否生成了定制的Desive控制器,还是使用了Gem提供的默认控制器?抱歉,我应该提供更多信息。我正在使用我自己的视图,我已经创建了一个用户控制器,请参见上面的编辑