Sha256: 5b8067948e9aae9d38091ac73b833628e88d6090b1549efd801e7f2ac8c99ddf

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module City

    def self.included(including_class)

      including_class.class_eval do

        include SubjModels::ComprisingExternalId

        has_and_belongs_to_many :actions
        has_many :offices
        has_many :users

        validates :name, presence: true, uniqueness: true

        scope :with_office, -> { joins(:offices).where("offices.id IS NOT NULL").group(:id) }

      end

    end

    def to_s
      name
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subj_models-0.4.1 lib/subj_models/city.rb
subj_models-0.4 lib/subj_models/city.rb