-
-
Save radar/1906350 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 Product < ActiveRecord::Base | |
| has_many :products_materials | |
| has_many :materials, :through => :products_materials | |
| end | |
| class Material < ActiveRecord::Base | |
| has_many :products_materials | |
| has_many :products, :through => :products_materials | |
| end | |
| class ProductsMaterial < ActiveRecord::Base | |
| belongs_to :product | |
| belongs_to :material | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
well i tried copying your above example line for liine but kept getting:
1.9.3-p0 :020 > p = Product.first
Product Load (28.6ms) SELECT "products".* FROM "products" LIMIT 1
=> #<Product id: 1, title: "teddy", created_at: "2012-02-25 04:28:14", updated_at: "2012-02-25 04:28:14">
1.9.3-p0 :021 > p.materials
NameError: uninitialized constant Product::ProductsMaterial
hmm, must be something simple