Recoverable is available to you if it’s included in your
User model:
class User < ActiveRecord::Base
devise :database_authenticatable, :timeoutable, :registerable, :recoverable, :rememberable, :trackable
...
end
How to:
Create a method in your controller that will call send_reset_password_instructions.
In users_controller.rb, add:
def generate_new_password_email
user = User.find(params[:user_id])
user.send_reset_password_instructions flash[:notice] = "Reset password instructions have been sent to #{user.email}."
redirect_to admin_user_path(user)
end
Create a route in routes.rb:
namespace :admin do
resources :users, only: :show do
post :generate_new_password_email
end
end
Create a simple form on your user’s show page in the admin.
In show.html.erb, add:
<%=form_tag(admin_user_generate_new_password_email_path(@user)) do %>
<%=submit_tag 'Send Reset Password Email', class: 'button', :confirm => 'Are you sure you want to email reset password instructions?' %>
<% end %>
That’s it! If you want to test this in your development environment,
you can configure your SMTP settings to send an email locally.
At the bottom of config/environments/development.rb, add:
From your user page in the admin panel,
you can now hit the “Send Reset Password Email” button,
and a new reset password email will be sent to the user.
52a1f476012809aaea004a32b20822defeba4a89
f7cb4e9d98a2242b98143521573678080e97af12
b3d154c4f462e9c3879469d2d49b1bf1618c5590
I want to use the recoverable method in Devise. https://stackoverflow.com/questions/41073348/how-do-i-enable-recoverable-in-devise https://www.codeschool.com/blog/2012/10/02/re-generating-forgot-password-emails-with-devise/
Recoverable is available to you if it’s included in your
User model:
How to:
Create a method in your controller that will call
send_reset_password_instructions
.In
users_controller.rb
, add:Create a route in
routes.rb
:Create a simple form on your user’s show page in the admin.
In
show.html.erb
, add:That’s it! If you want to test this in your development environment,
you can configure your SMTP settings to send an email locally.
At the bottom of
config/environments/development.rb
, add:Restart your local server.
From your user page in the admin panel,
you can now hit the “Send Reset Password Email” button,
and a new reset password email will be sent to the user.