SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Nov 6, 2005, 15:25 #1
- Join Date
- May 2003
- Location
- virginia
- Posts
- 988
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Rails application + sub applications + scaffold
Hi,
I'd like to create an admin suite, that contains sub applications. I want to be able to access my admin panel by going to '/admin' and be able to share the resources (models etc) within the related applications. Here is an example:
Display main page:
/admin/
Would display total products, last five orders
Products:
/admin/products
Display paging list etc.
Product Edit:
/admin/products/edit/1
Form for editing products
Orders:
/admin/orders
Display paging list etc.
Edit Order:
/admin/orders/edit/1
Store:
/store
Listing of products
Store Product:
/store/product/3
product details
Home Page:
/
How do I go about doing that while still using the scaffold generator? Can I specifiy a directory for the controllers to go into? like:
./script/generator scaffold products admin/products
- matt
-
Nov 6, 2005, 15:33 #2
- Join Date
- May 2003
- Location
- virginia
- Posts
- 988
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Another issue:
In my views folder I have generically named files like edit, new etc., but they'll be different for each action, obviously. How is this dealt with? Do I create actions like delete_product, new_product etc? instead of new, delete, edit etc.?
-matt
-
Nov 6, 2005, 16:26 #3Code:
ruby script/generate scaffold Admin::Product ruby script/generate scaffold Admin::Category
As for your second question, you can either accept the defaults and change the file names/controller methods afterwards, or you can run a command like so:
Code:ruby script/generate controller Product delete_product new_product
-
Nov 6, 2005, 16:47 #4
- Join Date
- May 2003
- Location
- virginia
- Posts
- 988
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OK cool. I did:
./script/generator scaffold --help
and found out more about the script. I didn't use the :: but a / instead and it seemed to resolve.
After I did the scaffold for admin/products, the browser/server wasn't finding it. I then created a new controller called admin with the index action. Still didn't work. So I restarted my computer. Then loaded the page. Then it found my admin index action. But still no admin/products. After I deleted the admin_controller I created, the admin/products page was finally working and now, everything is working great.
Thanks for your help,
matt
Bookmarks