Sha256: 4f4c0865e497348956743461bba55cf01f8ddbd6e818ae5b493cb388a323c96c

Contents?: true

Size: 575 Bytes

Versions: 13

Compression:

Stored size: 575 Bytes

Contents

class Province < ActiveRecord::Base
  # Scopes, Attrs, Etc.
  default_scope order("title ASC")

  # Relationships
  belongs_to :country
  has_one :tax_rate
  has_many :addresses
  
  # Validations
  validates_presence_of :title, :code
  validates_uniqueness_of :title, :code
  
  def self.options_for_select(options={})
    options[:add_blank] ||= false
    text_for_blank = options[:text_for_blank] || "All"
    provinces = Province.all.collect { |p| [p.title, p.id] }
    if options[:add_blank]
      provinces.unshift [text_for_blank, 0]
    end

    provinces
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
forge-cli-0.0.18 lib/forge/app/models/province.rb
forge-cli-0.0.17 lib/forge/app/models/province.rb
forge-cli-0.0.16 lib/forge/app/models/province.rb
forge-cli-0.0.15 lib/forge/app/models/province.rb
forge-cli-0.0.14 lib/forge/app/models/province.rb
forge-cli-0.0.13 lib/forge/app/models/province.rb
forge-cli-0.0.12 lib/forge/app/models/province.rb
forge-cli-0.0.11 lib/forge/app/models/province.rb
forge-cli-0.0.10 lib/forge/app/models/province.rb
forge-cli-0.0.9 lib/forge/app/models/province.rb
forge-cli-0.0.8 lib/forge/app/models/province.rb
forge-cli-0.0.7 lib/forge/app/models/province.rb
forge-cli-0.0.6 lib/forge/app/models/province.rb