Skip to content

Instantly share code, notes, and snippets.

@ralfting
Created March 25, 2015 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralfting/b017c43b955e0d2d83ae to your computer and use it in GitHub Desktop.
Save ralfting/b017c43b955e0d2d83ae to your computer and use it in GitHub Desktop.
User.rb
class User < ActiveRecord::Base
belongs_to :company
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
# Create a password reset token for this user, saves it encrypted and returns the raw token text
def setup_password_reset
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
self.reset_password_token = enc
self.reset_password_sent_at = Time.now.utc
self.save(validate: false)
return raw
end
def send_password_reset
token = setup_password_reset
DinamMailer.password_reset(self, token).deliver
end
handle_asynchronously :send_password_reset
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment