Sha256: a538a03dd3201ca9a5559cb1fe81066c5a8394b0d0a54513305a84da4328fe76

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

# == Schema Information
#
# Table name: company_locations
#
#  id                          :integer          not null, primary key
#  title                       :string(255)
#  shortname                   :string(255)
#  description_translations    :hstore           default({})
#  place_title_translations    :hstore           default({})
#  place_location_translations :hstore           default({})
#  location_id                 :string(255)
#  sort_order                  :integer          default(0)
#  notes_translations          :hstore           default({})
#  created_at                  :datetime
#  updated_at                  :datetime
#

class CompanyLocation < ActiveRecord::Base
  validates :title, :shortname, :location_id, presence: true

  default_scope -> { order("#{quoted_table_name}.sort_order") }

  translates :description, :place_title, :place_location, :notes

  has_many :phones, class_name: :LocationPhone, dependent: :destroy
  has_many :emails, class_name: :LocationEmail, dependent: :destroy
  accepts_nested_attributes_for :phones, reject_if: :all_blank, allow_destroy: true
  accepts_nested_attributes_for :emails, reject_if: :all_blank, allow_destroy: true

  def location_query
    location_id.gsub(/\s*place[\s_-]*id\s*?:\s*/i, 'place_id:')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/models/company_location.rb