Sha256: b4d765f60c0c1be7fbfab62a5a667c55d5e7935bb5fec0d8e6963c46a33a2695

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

module Guts
  # Site model
  class Site < ActiveRecord::Base
    include TrackableConcern
    
    validates :name, presence: true
    validates :domain, presence: true
    
    has_many :types
    has_many :categories
    has_many :navigations
    has_many :navigation_items
    has_many :navigation_metafields
    has_many :metafields, as: :fieldable
    has_many :tracks, as: :object
    has_many :media, as: :filable
    has_many :options
    
    trackable :create, :update, :destroy, fields: [:name]
    
    # Checks if a site is default
    # @return [Boolean]
    def default?
      self[:default] == true
    end
    
    # Sets the current site ID
    # @param [Integer] id the ID to use
    # @note I simply can not see a better way at the moment to handle this with default_scope
    def self.current_id=(id)
      Thread.current[:site_id] = id
    end
    
    # Gets the current site ID
    # @return [Integer] the ID
    # @note I simply can not see a better way at the moment to handle this with default_scope
    def self.current_id
      Thread.current[:site_id]
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
guts-1.4.0 app/models/guts/site.rb
guts-1.3.6 app/models/guts/site.rb
guts-1.3.5 app/models/guts/site.rb
guts-1.3.4 app/models/guts/site.rb
guts-1.3.3 app/models/guts/site.rb
guts-1.3.2 app/models/guts/site.rb
guts-1.3.1 app/models/guts/site.rb
guts-1.3.0 app/models/guts/site.rb
guts-1.2.2 app/models/guts/site.rb
guts-1.2.1 app/models/guts/site.rb
guts-1.2.0 app/models/guts/site.rb
guts-1.1.1 app/models/guts/site.rb
guts-1.1.0 app/models/guts/site.rb