How do you customize this default line generated by Devise in the mailer view?
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
I've written a method in my controller called user_confirm
. And I have also defined a route for it. Can I get the URL to link to that method with token as the params?
I used this routing:
map.user_confirm 'confirm/:confirmation_token',
:controller => 'confirmations', :action => 'show'
And this ERB:
<%= link_to 'Confirm my account',
user_confirm_url(:confirmation_token => @resource.confirmation_token) %>
And got this nice link:
http://localhost:3000/confirm/RjOnrd5yNREEDwsEfiFa
Its something like (in routes.rb):
devise_scope :user do
match '/confirm/:confirmation_token', :to => "devise/confirmations#show", :as => "user_confirm", :only_path => false
end
and in views you can use something like:
<%= link_to 'Confirm my account', user_confirm_url(@resource.confirmation_token) %>
for Rails 3.
rails 4.0.5
devise 3.2.4
url:
http://example.com/users/confirmation?confirmation_token=jevYKv1z9Pr1LsAUB2NX
app/views/devise/mailer/confirmation_instructions.html.erb:
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
config/routes.rb:
devise_scope :user do
get 'confirm/:confirmation_token', to: 'devise/confirmations#show'
end
app/views/devise/mailer/confirmation_instructions.html.erb:
<p><%= link_to 'Confirm my acount', confirm_url(@token) %></p>
url:
http://example.com/confirm/Kezap1iutgvXyQAhyu64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With