Sha256: 0adf8dc460e160ed35a590dab54515e29456f578daae18b2d134a2a4090224f2

Contents?: true

Size: 862 Bytes

Versions: 11

Compression:

Stored size: 862 Bytes

Contents

class Address < ActiveRecord::Base
  has_many :bills, :class_name => 'Order', :foreign_key => "billing_address_id"
  has_many :shipments, :class_name => 'Order', :foreign_key => "shipping_address_id"
  belongs_to :country 
  belongs_to :province

  validates_presence_of :first_name
  validates_presence_of :last_name
  validates_presence_of :address1
  validates_presence_of :city
  # it seems like an address should have a province, but if you have to be able to not enter one for countries where they
  # don't have them / don't have them entered
  # validates_presence_of :province
  validates_presence_of :postal
  validates_presence_of :country_id
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i

  # open up everything for mass assignment
  attr_protected

  def self.valid_types
    ['billing', 'shipping']
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/app/models/address.rb
forge-cli-0.1.9 lib/forge/app/models/address.rb
forge-cli-0.1.8 lib/forge/app/models/address.rb
forge-cli-0.1.7 lib/forge/app/models/address.rb
forge-cli-0.1.6 lib/forge/app/models/address.rb
forge-cli-0.1.5 lib/forge/app/models/address.rb
forge-cli-0.1.4 lib/forge/app/models/address.rb
forge-cli-0.1.3 lib/forge/app/models/address.rb
forge-cli-0.1.2 lib/forge/app/models/address.rb
forge-cli-0.1.1 lib/forge/app/models/address.rb
forge-cli-0.1.0 lib/forge/app/models/address.rb