Module: HasTokenId::Concern
- Defined in:
- lib/has_token_id/concern.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/has_token_id/concern.rb', line 4 def self.included(base) base.send(:extend, ClassMethods) base.send(:include, InstanceMethods) base.class_eval do validates :token, presence: true, uniqueness: true before_validation :generate_token, on: :create, if: proc{|record| record.token.nil? } end end |