Class: Alchemy::Site
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- Alchemy::Site
- Includes:
- Layout
- Defined in:
- app/models/alchemy/site.rb
Defined Under Namespace
Modules: Layout
Constant Summary
Constants included from Layout
Constants included from SearchableResource
Alchemy::SearchableResource::SEARCHABLE_COLUMN_TYPES
Class Method Summary collapse
-
.current ⇒ Object
deprecated
Deprecated.
Use Current#site instead.
-
.current=(site) ⇒ Object
deprecated
Deprecated.
Use Current#site= instead.
- .find_for_host(host) ⇒ Object
- .find_in_aliases(host) ⇒ Object
Instance Method Summary collapse
-
#current? ⇒ Boolean
Returns true if this site is the current site.
-
#default_language ⇒ Object
The default language for this site.
-
#to_partial_path ⇒ Object
Returns the path to site’s view partial.
Methods included from Layout
#definition, #page_layout_definitions, #page_layout_names, #partial_name
Methods included from SearchableResource
#ransackable_associations, #ransackable_attributes, #ransortable_attributes
Class Method Details
.current ⇒ Object
Use Current#site instead.
67 68 69 |
# File 'app/models/alchemy/site.rb', line 67 def current Current.site end |
.current=(site) ⇒ Object
Use Current#site= instead.
61 62 63 |
# File 'app/models/alchemy/site.rb', line 61 def current=(site) Current.site = site end |
.find_for_host(host) ⇒ Object
75 76 77 78 79 80 |
# File 'app/models/alchemy/site.rb', line 75 def find_for_host(host) # These are split up into two separate queries in order to run the # fastest query first (selecting the domain by its primary host name). # find_by(host: host) || find_in_aliases(host) || first end |
.find_in_aliases(host) ⇒ Object
82 83 84 85 86 87 88 |
# File 'app/models/alchemy/site.rb', line 82 def find_in_aliases(host) return nil if host.blank? all.find do |site| site.aliases.split.include?(host) if site.aliases.present? end end |
Instance Method Details
#current? ⇒ Boolean
Returns true if this site is the current site
37 38 39 |
# File 'app/models/alchemy/site.rb', line 37 def current? Current.site == self end |
#default_language ⇒ Object
The default language for this site
There can only be one default language per site.
55 56 57 |
# File 'app/models/alchemy/site.rb', line 55 def default_language languages.find_by(default: true) end |
#to_partial_path ⇒ Object
Returns the path to site’s view partial.
Site view partials live in app/views/alchemy/site_layouts
Please use rails g alchemy:site_layouts
to generate partials for all your sites.
47 48 49 |
# File 'app/models/alchemy/site.rb', line 47 def to_partial_path "alchemy/site_layouts/#{partial_name}" end |