Generate URL for password reset manually using devise

Ruby

Assumptions

  • Resource name is User
  • Resource ID is 1

Execute on rails console

user = User.find(1)

raw, enc = Devise.token_generator.generate(user.class, :reset_password_token)

user.reset_password_token   = enc
user.reset_password_sent_at = Time.now.utc
user.save(:validate => false)

def main_app
  Rails.application.class.routes.url_helpers
end


include Devise::Controllers::UrlHelpers

edit_password_path(user, :reset_password_token => raw)

Comments

タイトルとURLをコピーしました