public
Description: open-source e-commerce built on merb
Clone URL: git://github.com/myabc/merb_mart.git
Search Repo:
Click here to lend your support to: merb_mart and make a donation at www.pledgie.com !
myabc (author)
Wed May 07 19:06:13 -0700 2008
commit  8388fe58541d56708c0b85fcc0e940d7946c9179
tree    f487fe69713a945be289f5f413e211423be8ff01
parent  cc109e953862f2a7501b1d033612a5dac4ec2644
merb_mart / app / models / address.rb
100644 38 lines (30 sloc) 1.142 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Address
 
  include DataMapper::Resource
  include DataMapper::Validate
 
  property :first_name, String, :length => 50, :nullable => false
  property :last_name, String, :length => 50, :nullable => false
  property :company, String, :length => 100
  property :telephone, String, :length => 20
  property :address1, String, :length => 200, :nullable => false
  property :address2, String, :length => 200
  property :city, String, :length => 50
  property :postal_code, String, :length => 10
  property :state_id, Fixnum # foreign-key
  property :country_code, String # foreign-key
 
  belongs_to :state
  belongs_to :country
 
  validates_presence_of :first_name
  validates_presence_of :last_name
  validates_presence_of :address1
  validates_presence_of :postal_code
 
  validates_length_of :first_name, :maximum => 50
  validates_length_of :last_name, :maximum => 50
  validates_length_of :address1, :maximum => 255
 
  alias :zipcode :postal_code
  alias :zipcode= :postal_code=
  alias :province :state
  alias :province= :state=
 
  def name
    "#{self.first_name} #{self.last_name}"
  end
 
end