Sha256: bffd9d841b7dc66f3a9b7591b19702e9e87b46551e4f09431d12effc040c54a0

Contents?: true

Size: 1.1 KB

Versions: 32

Compression:

Stored size: 1.1 KB

Contents

class Country < ActiveRecord::Base
  attr_accessible :name, :display_name, :alpha_2, :alpha_3, :numeric_3, :note
  include MasterModel
  default_scope :order => "countries.position"
  has_many :patrons
  #has_many :people
  #has_many :corporate_bodies
  #has_many :families
  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

  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
end

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

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
enju_biblio-0.1.0.pre42 app/models/country.rb
enju_biblio-0.1.0.pre41 app/models/country.rb
enju_biblio-0.1.0.pre40 app/models/country.rb
enju_biblio-0.1.0.pre39 app/models/country.rb
enju_biblio-0.1.0.pre38 app/models/country.rb
enju_biblio-0.1.0.pre37 app/models/country.rb
enju_biblio-0.1.0.pre36 app/models/country.rb
enju_biblio-0.1.0.pre35 app/models/country.rb
enju_biblio-0.1.0.pre34 app/models/country.rb
enju_biblio-0.1.0.pre33 app/models/country.rb
enju_biblio-0.1.0.pre32 app/models/country.rb
enju_biblio-0.1.0.pre31 app/models/country.rb
enju_biblio-0.1.0.pre30 app/models/country.rb
enju_biblio-0.1.0.pre29 app/models/country.rb
enju_biblio-0.1.0.pre28 app/models/country.rb
enju_biblio-0.1.0.pre27 app/models/country.rb
enju_biblio-0.1.0.pre26 app/models/country.rb
enju_biblio-0.1.0.pre25 app/models/country.rb
enju_biblio-0.1.0.pre24 app/models/country.rb
enju_biblio-0.1.0.pre23 app/models/country.rb