Sha256: a536166a22201f6cdfc1111fd12a13260a4cef74df1c83712a2c08c36b617181
Contents?: true
Size: 529 Bytes
Versions: 1
Compression:
Stored size: 529 Bytes
Contents
module Workarea::SharableToken extend ActiveSupport::Concern include ActiveRecord::SecureToken included do field :sharable_token, type: String index({ sharable_token: 1 }) has_secure_token before_validation :ensure_token_exists end module ClassMethods def find_by_token(sharable_token) find_by(sharable_token: sharable_token) rescue nil end end private def ensure_token_exists self.sharable_token = self.class.generate_unique_secure_token if sharable_token.blank? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
workarea-cart_sharing-1.0.2.pre | config/initializers/sharable_token.rb |