在里面
设计
gem,确认路由创建如下:,
# # Confirmation routes for Confirmable, if User model has :confirmable configured
# new_user_confirmation GET /users/confirmation/new(.:format) {controller:"devise/confirmations", action:"new"}
# user_confirmation GET /users/confirmation(.:format) {controller:"devise/confirmations", action:"show"}
# POST /users/confirmation(.:format) {controller:"devise/confirmations", action:"create"}
所以如果你想创建像这样的url,
http://something.com/users/confirmation?confirmation_token=CV3zV1wAWsb3RokHHEKN
user_confirmation_url(confirmation_token: @resource.confirmation_token)`
而不是
user_confirmation_url(@resource, confirmation_token: @resource.confirmation_token)`
也检查
如果你想通过
用户名
数据库属性
@resource
在确认url中(正如您通过在url中传递'divyanshu rawat'所要求的那样),您可以创建自己的自定义路由,该路由将指向同一控制器&行动如下:,
# config/routes.rb
devise_for :users
as :user do
get '/users/confirmation/:name' => "devise/confirmations#show", as: 'user_confirm'
end
confirmation_instructions.html.haml
如下:,
%p Welcome #{@resource.first_name}!
%p You can confirm your account email through the link below:
%p= link_to 'Confirm my account', user_confirm_url(name: @resource.user_name, confirmation_token: @resource.confirmation_token)
这将产生类似url的,
http://something.com/users/confirmation/divyanshu-rawat?confirmation_token=CV3zV1wAWsb3RokHHEKN