Created
May 26, 2011 14:40
-
-
Save arbarlow/993283 to your computer and use it in GitHub Desktop.
This file contains 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 Order < ActiveRecord::Base | |
has_many :order_products | |
validates_associated :order_products # This checks all the order_product instances are valid | |
end | |
class OrderProduct < ActiveRecord::Base | |
belongs_to :order | |
belongs_to :product | |
validates :order, :product, :presence => true | |
end | |
class Product < ActiveRecord::Base | |
has_many :order_products | |
validates :name, :description, :price, :presence => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment