# Scaffolding in a sub-directory on Rails 2.x

**URL:** <https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358>\
**Category:** Rails\
**Created:** [August 7, 2009, 9:25am UTC](https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358 "2009-08-07T09:25:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisnzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@chrisnzi](https://www.ruby-forum.com/u/chrisnzi)\
**Post date:** [August 7, 2009, 9:25am UTC](https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358/1 "2009-08-07T09:25:05Z")

</div>

Hi, I’m trying to make an app using rails 2.x, but when I try to  
generate scaffold it messes up with several errors. For example, I  
want to make an scaffold this way, localhost:3000/admin/publisher, but  
I don’t know how I can generate it;

I was trying to generate it by ./script/generate scaffold ‘admin/  
publisher’ name:string, but I doesn’t work… It gave me an error  
that tells me publishers database doesn’t exists!!!

Can anyone help me into this thing…??? How am I supposed to make it  
work???

Thanks in advance!

Christian

---

<div class="post-metadata">

**Author:** ![chrisnzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@chrisnzi](https://www.ruby-forum.com/u/chrisnzi)\
**Post date:** [August 7, 2009, 9:44am UTC](https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358/2 "2009-08-07T09:44:16Z")

</div>

Hi  
you can do like  
./script/generate scaffold Admin::Publisher

```
Here the model be namespaced And if you need only controllers and 

```

view you can do it seperately

./script/generate controller Admin::Publisher  
./script/generate model Publisher

```
 And edit routes.rb

```

map.namespace(:admin) do |admin|  
map.resources :publishers  
end

Sijo

---

<div class="post-metadata">

**Author:** ![chrisnzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@chrisnzi](https://www.ruby-forum.com/u/chrisnzi)\
**Post date:** [August 7, 2009, 8:21pm UTC](https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358/3 "2009-08-07T20:21:54Z")

</div>

Thanks Sijo, I followed your instructions but there’s another error I  
got  
Routing Error

No route matches “/admin/publisher” with {:method=\>:get}

Do you know a way to get rid of it…??

Thanks

2009/8/7 Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![chrisnzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@chrisnzi](https://www.ruby-forum.com/u/chrisnzi)\
**Post date:** [August 8, 2009, 6:46am UTC](https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358/4 "2009-08-08T06:46:22Z")

</div>

Hi

Not only doing the above solves all…You have to edit a lot of  
places. Rather than I explain all these and grab a lot more spaces here  
you better read this  
Read section Namespaced Routes in

> **[Rolling with Rails 2.0 - The First Full Tutorial - Part 1 | AkitaOnRails.com](https://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial)**
>
> for brazilians: click here.
> I am very happy to see that my Rails 2.0 Screencast was very well received. More than 1,500 unique visitors watched it...

Sijo

---

<div class="post-metadata">

**Author:** ![chrisnzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@chrisnzi](https://www.ruby-forum.com/u/chrisnzi)\
**Post date:** [August 8, 2009, 8:57am UTC](https://www.ruby-forum.com/t/scaffolding-in-a-sub-directory-on-rails-2-x/173358/5 "2009-08-08T08:57:59Z")

</div>

Sijo Kg wrote:

> Hi
> 
> Not only doing the above solves all…You have to edit a lot of  
> places. Rather than I explain all these and grab a lot more spaces here  
> you better read this  
> Read section Namespaced Routes in
> 
> [Rolling with Rails 2.0 - The First Full Tutorial - Part 1 | AkitaOnRails.com](http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial)
> 
> Sijo

There is a totally superb blog on this that I use all the time  
[http://icebergist.com/posts/restful-admin-namespaced-controller-using-scaffolding](http://icebergist.com/posts/restful-admin-namespaced-controller-using-scaffolding)  
Clear, concise and it works!
