# Noob question regarding site and table naming structure

**URL:** <https://www.ruby-forum.com/t/noob-question-regarding-site-and-table-naming-structure/137058>\
**Category:** Rails\
**Created:** [May 8, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/noob-question-regarding-site-and-table-naming-structure/137058 "2008-05-08T16:52:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blzabub](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@blzabub](https://www.ruby-forum.com/u/blzabub)\
**Post date:** [May 8, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/noob-question-regarding-site-and-table-naming-structure/137058/1 "2008-05-08T16:52:58Z")

</div>

I’m a newbie at Rails and Ruby so please bear with me:

I’m trying to build a simple application that has an administration  
system that manages organizations and products. I want the model/views/  
controllers for ‘organizations’ and ‘products’ to be within the  
‘admin’ part of the site, so I created a controller for admin first:

generate controller admin

then I created scaffolding like thus:

generate scaffold admin/organization  
generate scaffold admin/product

everything seems fine so far, the tables created through the migration  
were admin\_organizations and admin\_products which is fine, until I try  
to access the index view for either organizations or products, at  
which point I get the error:

Table ‘wyforg\_development.products’ doesn’t exist: SELECT \* FROM  
`products`

which makes sense since the table is called ‘admin\_products’ not  
‘products’. I assume the way to address this is not to rename the  
tables ‘products’ and ‘organizations’, dropping the ‘admin\_’ prefix,  
but by some other method of overriding the default configuration of  
the scaffolding, but I can’t figure out where to do this and how.  
Thanks for any help.

~Ben

---

<div class="post-metadata">

**Author:** ![blzabub](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@blzabub](https://www.ruby-forum.com/u/blzabub)\
**Post date:** [May 8, 2008, 11:33pm UTC](https://www.ruby-forum.com/t/noob-question-regarding-site-and-table-naming-structure/137058/2 "2008-05-08T23:33:12Z")

</div>

It took me most of the day, but I think I understand a little bit  
better now. If anyone reading this finds fault with this approach,  
please comment, I’m still struggling to understand why things work or  
don’t.

I modified the routes.rb file to replace this:

map.resources :organizations

with this:

map.namespace :admin do |admin|  
admin.resources :organizations  
end

But it would still throw a database error. So I had to add this to the  
model:

set\_table\_name “admin\_organizations”

I’m not sure whether this is the correct way to do things or not but  
it seems to work after modifying various views.
