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
questions.
I have a database with three tables:
users
items
item_types
I’ve generated three models:
User
Item
ItemType
I’ve generated one controller so far:
Admin
Now, if I can generate a scaffold for my Admin controller using any
single model, but how about all three? Typically the directory
structure is:
application/controller/action
But what if I want:
application/controller/subapp/action
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)?
