# Multiple Scaffolds

**URL:** <https://www.ruby-forum.com/t/multiple-scaffolds/59539>\
**Category:** Rails\
**Created:** [May 3, 2006, 11:23pm UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539 "2006-05-03T23:23:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [May 3, 2006, 11:23pm UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539/1 "2006-05-03T23:23:18Z")

</div>

I’d like to create scaffolds for each of the tables in my database, but  
would like to access them below the path: localhost:3000/admin

For example localhost:3000/admin/table1  
localhost:3000/admin/table2

Where table1 and table2 would be the controller names respectively,  
calling their own list.rhtml, show.rhtml, edit.rhtml, etc…

Any recommendations on how/where to utilize multiple scaffolds?

Thanks!

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [May 3, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539/2 "2006-05-03T23:47:00Z")

</div>

You can create scaffolds in seperate modules by doing this:

ruby script/generate scaffold Admin::Model1  
ruby script/generate scaffold Admin::Model2

The controllers will then be accessible via:  
/admin/model1/ (list/edit/show etc)  
/admin/model2/ (list/edit/show etc)

Hope that helps,

Steve

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [May 4, 2006, 12:34am UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539/3 "2006-05-04T00:34:21Z")

</div>

Stephen,

That did work indeed. Thanks!

However, I had to make sure I didn’t already have an admin\_controller.rb  
at the root.

The admin\_controller.rb in the /admin directory of /admin/model1 was  
attempting to call an action “model1”. Maybe there’s a way to make the  
controller ignore that and execute the /admin/model1\_controller.rb  
instead.

But for now, I deleted the admin\_controller.rb on the root.

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [March 15, 2007, 9:00am UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539/4 "2007-03-15T09:00:28Z")

</div>

ryan wrote:

> The admin\_controller.rb in the /admin directory of /admin/model1 was  
> attempting to call an action “model1”. Maybe there’s a way to make the  
> controller ignore that and execute the /admin/model1\_controller.rb  
> instead.

Is there anyway to use static scaffolds, have an admin\_controller and  
have the model1\_controller and model2\_controllers in the /admin/  
directory? I would like to be able to have admin go to railsapp/admin  
and then be able to click links to go to the actions to crud model1 and  
model2 but still have static scaffolds to work with.

Best,  
Sam

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [March 18, 2007, 5:07pm UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539/5 "2007-03-18T17:07:43Z")

</div>

See this post:  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/c835bd6eca8598c2/298b8b0b2cdccac4?lnk=gst&q=controller+subdirectory&rnum=3&hl=en#298b8b0b2cdccac4](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c835bd6eca8598c2/298b8b0b2cdccac4?lnk=gst&q=controller+subdirectory&rnum=3&hl=en#298b8b0b2cdccac4)

On Mar 15, 3:00 am, Sam W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [May 4, 2006, 3:29am UTC](https://www.ruby-forum.com/t/multiple-scaffolds/59539/6 "2006-05-04T03:29:37Z")

</div>

On 5/3/06, ryan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> instead.
> 
> But for now, I deleted the admin\_controller.rb on the root.

You could always keep the admin\_controller.rb in app/controllers and  
do the following in your AdminController:

scaffold :model1, :suffix=\>true  
scaffold :model2, :suffix=\>true

Then you can access the scaffolds at /admin/list\_model1 and  
admin/list\_model2.

Also, you may want to check out the Scaffolding Extensions Plugin[1],  
which greatly enhances the default scaffolding.

Jeremy

[1]  
[http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin](http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin)
