Sha256: d4237e711a541fc411732378a91957faae2025ced31e4635cea215c72e380679

Contents?: true

Size: 1.07 KB

Versions: 22

Compression:

Stored size: 1.07 KB

Contents

class Country < ApplicationRecord
  include MasterModel
  default_scope { order('countries.position') }
  has_many :agents
  has_many :libraries
  has_one :library_group

  # If you wish to change the field names for brevity, feel free to enable/modify these.
  # alias_attribute :iso, :alpha_2
  # alias_attribute :iso3, :alpha_3
  # alias_attribute :numeric, :numeric_3

  # Validations
  validates_presence_of :alpha_2, :alpha_3, :numeric_3
  validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }

  after_save :clear_all_cache
  after_destroy :clear_all_cache

  def self.all_cache
    Rails.cache.fetch('country_all'){Country.all.to_a}
  end

  def clear_all_cache
    Rails.cache.delete('country_all')
  end

  private

  def valid_name?
    true
  end
end

# == Schema Information
#
# Table name: countries
#
#  id           :integer          not null, primary key
#  name         :string           not null
#  display_name :text
#  alpha_2      :string
#  alpha_3      :string
#  numeric_3    :string
#  note         :text
#  position     :integer
#

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
enju_biblio-0.3.18 app/models/country.rb
enju_biblio-0.3.17 app/models/country.rb
enju_biblio-0.3.16 app/models/country.rb
enju_biblio-0.3.15 app/models/country.rb
enju_biblio-0.3.14 app/models/country.rb
enju_biblio-0.3.13 app/models/country.rb
enju_biblio-0.3.12 app/models/country.rb
enju_biblio-0.3.11 app/models/country.rb
enju_biblio-0.3.10 app/models/country.rb
enju_biblio-0.3.10.rc.3 app/models/country.rb
enju_biblio-0.3.10.rc.2 app/models/country.rb
enju_biblio-0.3.10.rc.1 app/models/country.rb
enju_biblio-0.3.9 app/models/country.rb
enju_biblio-0.4.0.rc.1 app/models/country.rb
enju_biblio-0.3.8 app/models/country.rb
enju_biblio-0.3.7 app/models/country.rb
enju_biblio-0.3.6 app/models/country.rb
enju_biblio-0.4.0.beta.2 app/models/country.rb
enju_biblio-0.4.0.beta.1 app/models/country.rb
enju_biblio-0.3.5 app/models/country.rb