I’m new to rails, trying to get a basic understanding and I’ve
encountered two concepts I can’t wrap my head around and can’t find
answers for elsewhere. I’ve been looking for answers for hours and
can’t seem to get anywhere. I apologize in advance for the really basic
I have a database with three tables:
I’ve generated three models:
I’ve generated one controller so far:
Now, if I can generate a scaffold for my Admin controller using any
single model, but how about all three? Typically the directory
But what if I want:
Basically, I’d like to generate scaffolds for:
/admin/user/list (edit/new/delete/show, etc)
/admin/item/list (edit/new/delete/show, etc)
/admin/itemtype/list (edit/new/delete/show, etc)
Is this possible? If not, what is the alternative?
Second, my Item model contains an integer field “parent.” The field
contains either 0 or a valid item_id … so it’s self referencing. Some
items belong to other items.
I know how to setup a has_one or has_many relationship using different
models, but how do I specify that the product field points back to
another model (if it does not contain 0)?