app/models/spotlight/exhibit.rb in blacklight-spotlight-0.0.2 vs app/models/spotlight/exhibit.rb in blacklight-spotlight-0.0.3
- old
+ new
@@ -7,17 +7,19 @@
has_many :feature_pages
has_one :home_page
has_many :home_pages
has_many :users, through: :roles, class_name: '::User'
has_many :custom_fields
+ has_many :contacts
+ has_one :blacklight_configuration, class_name: Spotlight::BlacklightConfiguration
- belongs_to :blacklight_configuration, class_name: Spotlight::BlacklightConfiguration
accepts_nested_attributes_for :blacklight_configuration
accepts_nested_attributes_for :searches
accepts_nested_attributes_for :about_pages
accepts_nested_attributes_for :feature_pages
- accepts_nested_attributes_for :roles, allow_destroy: true
+ accepts_nested_attributes_for :contacts
+ accepts_nested_attributes_for :roles, allow_destroy: true, reject_if: proc {|attr| attr['user_key'].blank?}
delegate :blacklight_config, to: :blacklight_configuration
serialize :facets, Array
serialize :contact_emails, Array
@@ -41,10 +43,10 @@
attributes_collection = emails.is_a?(Hash) ? emails.values : emails
self.contact_emails = attributes_collection.map {|e| e['email']}.reject(&:blank?)
end
def main_about_page
- about_pages.published.first
+ @main_about_page ||= about_pages.published.first
end
# Find or create the default exhibit
def self.default
self.find_or_create_by!(name: DEFAULT) do |e|