Class: Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Site
- Defined in:
- app/models/site.rb
Class Method Summary collapse
Instance Method Summary collapse
- #email_from ⇒ Object
- #grouped_activities ⇒ Object
- #multi_sites_enabled? ⇒ Boolean
- #owner ⇒ Object
- #owners ⇒ Object
-
#perma_host ⇒ Object
def tag_counts Content.tag_counts :conditions => “site_id = #id” end.
- #plugins ⇒ Object
- #section_ids ⇒ Object
Class Method Details
.bust_cache! ⇒ Object
37 38 39 |
# File 'app/models/site.rb', line 37 def bust_cache! all.each(&:touch) end |
.find_by_host!(host) ⇒ Object
32 33 34 35 |
# File 'app/models/site.rb', line 32 def find_by_host!(host) return Site.first if count == 1 && !multi_sites_enabled where("? = ANY (hosts)", host).first or raise ActiveRecord::RecordNotFound end |
Instance Method Details
#email_from ⇒ Object
80 81 82 |
# File 'app/models/site.rb', line 80 def email_from "#{name} <#{email}>" unless name.blank? || email.blank? end |
#grouped_activities ⇒ Object
67 68 69 |
# File 'app/models/site.rb', line 67 def grouped_activities activities.find_coinciding_grouped_by_dates(Time.zone.now.to_date, 1.day.ago.to_date) end |
#multi_sites_enabled? ⇒ Boolean
42 43 44 |
# File 'app/models/site.rb', line 42 def multi_sites_enabled? self.class.multi_sites_enabled end |
#owner ⇒ Object
50 51 52 |
# File 'app/models/site.rb', line 50 def owner nil end |
#owners ⇒ Object
46 47 48 |
# File 'app/models/site.rb', line 46 def owners [] end |
#perma_host ⇒ Object
63 64 65 |
# File 'app/models/site.rb', line 63 def perma_host host.sub(':', '.') # Needed to create valid directories in ms-win end |
#plugins ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'app/models/site.rb', line 71 def plugins @plugins ||= Rails.plugins.values.inject(ActiveSupport::OrderedHash.new) do |plugins, plugin| plugin = plugin.clone plugin.owner = self plugins[plugin.name.to_sym] = plugin plugins end end |
#section_ids ⇒ Object
54 55 56 57 |
# File 'app/models/site.rb', line 54 def section_ids types = Section.types.map { |type| "'#{type}'" }.join(', ') self.class.connection.select_values("SELECT id FROM contents WHERE type IN (#{types}) AND site_id = #{id}") end |