Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ActiveRecord::Base
- include TokenGenerator
- before_save :set_token
- private
- def set_token
- if self.token.blank?
- write_attribute :token, generate_token(9) { |token| self.class.find_by_token(token).nil? }
- end
- true
- end
- end
Add Comment
Please, Sign In to add comment