Created
June 15, 2009 12:43
-
-
Save leehambley/130077 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Address < ActiveRecord::Base | |
belongs_to :customer | |
validates_presence_of :line_1, :city, :postcode | |
validates_format_of :tag, :with => MVOR::Patterns.dashed_word, :allow_blank => true | |
belongs_to :addressable, :polymorphic => true | |
def expendable? | |
# pending | |
true | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer < User | |
# The rest of the `user` attributes are implicitly protected by | |
# an explicit declaration of accessible attributes in the | |
# User class. | |
attr_accessible :business, :account_address, :addresses | |
has_many :orders | |
has_many :addresses, :as => :addressable | |
accepts_nested_attributes_for :addresses | |
has_one :account_address, :as => :addressable, :class_name => 'Address', :conditions => ['tag = ?','account-address'] | |
accepts_nested_attributes_for :account_address | |
# ..... snip ..... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment