Sha256: 8fa135a02073c19f4a5bdd7315ffb64f22fa771461c0e2ba34df36e4e375c5bf

Contents?: true

Size: 531 Bytes

Versions: 8

Compression:

Stored size: 531 Bytes

Contents

require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module CityModule

    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

8 entries across 8 versions & 1 rubygems

Version Path
subj_models-0.5.6 lib/subj_models/city.rb
subj_models-0.5.5 lib/subj_models/city.rb
subj_models-0.5.4 lib/subj_models/city.rb
subj_models-0.5.3 lib/subj_models/city.rb
subj_models-0.5.2 lib/subj_models/city.rb
subj_models-0.5.1 lib/subj_models/city.rb
subj_models-0.4.3 lib/subj_models/city.rb
subj_models-0.4.2 lib/subj_models/city.rb