Hello all
This is my first post so excuse the basic question. (and any repeats I
just
got an email saying this post was too big so I have re-submitted a
smaller
version)
I was following the thread on
http://lists.rubyonrails.org/pipermail/rails/2006-May/038988.html
regarding
the STI on HABTM for RoR.
I have a very similar problem and was hoping for some help.
I have the following models that employ single table inheritance and
HABTM
(see below for sql script showing tables). I read that the classes will
inherit the HABTM relationship from the parent class. Eg Part should
understand habtm because his father does. Is this correct?
class Product < ActiveRecord::Base
belongs_to :category
has_and_belongs_to_many :items
end
class Item < ActiveRecord::Base
has_and_belongs_to_many :products
end
class Part < Item
end
class Accessory < Item
end
I have created part and accessory controllers/crud views and have
attempted
to do the following but it doesn’t appear that the HABTM relationship is
in
place.
From the products_controller I attempt the following:
#populate collections for _partials
@parts = @product.parts.find_all
@accessories = @product.accessories.find_all
But get the following error.
Undefined method `parts’
Any suggestions?
Regards,
Adam
------------sql script
----------------------
create tables
----------------------
CREATE TABLE categories
(
CREATE TABLE products
(
CREATE TABLE items
(
CREATE TABLE attachments
(
----------------------
create join tables
----------------------
CREATE TABLE items_products (
CREATE TABLE attachments_products (
CREATE TABLE attachments_items (