Sha256: dfc99de576400bc6a62fca0dfddb3bd3ef621680b64d6c3ffb733d5de54a3b0a
Contents?: true
Size: 757 Bytes
Versions: 11
Compression:
Stored size: 757 Bytes
Contents
module Spree class Store < Spree::Base validates :code, presence: true, uniqueness: { allow_blank: true } validates :name, presence: true validates :url, presence: true validates :mail_from_address, presence: true before_create :ensure_default_exists_and_is_unique scope :by_url, lambda { |url| where("url like ?", "%#{url}%") } def self.current(domain = nil) current_store = domain ? Store.by_url(domain).first : nil current_store || Store.default end def self.default where(default: true).first || new end private def ensure_default_exists_and_is_unique if default Store.update_all(default: false) else self.default = true end end end end
Version data entries
11 entries across 11 versions & 1 rubygems