Sha256: 4862955dc844e130829a895b9d9768d056395249bc12598d08a235fe945a0f90

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

class Spotlight::Contact < ActiveRecord::Base
  belongs_to :exhibit, touch: true
  scope :published, -> { where(show_in_sidebar: true) }
  default_scope { order("weight ASC") }
  serialize :contact_info, Hash

  extend FriendlyId
  friendly_id :name, use: [:slugged,:scoped,:finders], scope: :exhibit

  mount_uploader :avatar, Spotlight::AvatarUploader

  ## carrierwave-crop doesn't want to store the crop points. we do.
  # so instead of this:
  #crop_uploaded :avatar  ## Add this
  # we do this:
  after_save do
    recreate_avatar_versions if avatar.present?
  end

  before_save on: :create do
    self.show_in_sidebar = true if show_in_sidebar.nil?
  end

  def self.fields
    @fields ||= {title:     {itemprop: 'jobTitle'},
                 location:  {itemprop: 'workLocation'},
                 email:     {helper: :render_contact_email_address},
                 telephone: {}}
  end

  protected
  def should_generate_new_friendly_id?
    name_changed?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-0.3.1 app/models/spotlight/contact.rb
blacklight-spotlight-0.3.0 app/models/spotlight/contact.rb
blacklight-spotlight-0.2.0 app/models/spotlight/contact.rb