diff --git a/app/models/site.rb b/app/models/site.rb index 4a4c05e8..ce689200 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -16,6 +16,7 @@ class Site field :department has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :footer, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_many :site_metas, :autosave => true, :dependent => :destroy before_save :set_key @@ -40,6 +41,10 @@ class Site @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil end + def footer + @footer ||= I18nVariable.first(:conditions => {:key => 'footer', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + METAS.each do |meta| define_method meta do fetch_meta = self.site_metas.where(key: meta).limit(1) @@ -58,7 +63,8 @@ class Site protected def set_key - title.key = 'title' if title + title.key = 'title' if title && (title.key.blank? rescue true) + footer.key = 'footer' if footer && (footer.key.blank? rescue true) end end diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 5fce6331..93e1a358 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -14,18 +14,30 @@