# Organizing controllers and models

**URL:** <https://www.ruby-forum.com/t/organizing-controllers-and-models/132341>\
**Category:** Rails\
**Created:** [March 19, 2008, 9:14am UTC](https://www.ruby-forum.com/t/organizing-controllers-and-models/132341 "2008-03-19T09:14:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dharmarth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3e96dc/32.png) [@dharmarth](https://www.ruby-forum.com/u/dharmarth)\
**Post date:** [March 19, 2008, 9:14am UTC](https://www.ruby-forum.com/t/organizing-controllers-and-models/132341/1 "2008-03-19T09:14:11Z")

</div>

What can be the ways to organize Controllers and Models into proper  
hierarchy? This is essential, as in my application, there are 3-4  
controller and 5-6 models corresponding to one service. And there can be  
hundreads of service added later on. If I am putting all the contollers  
and models in the same directory, it will become very bulky and even  
there may be name conflicts.  
So I organized it under different directories under the controllers and  
models.  
I created module1 directory under controllers and written controller as  
follows.

test1\_controller.rb  
class Module1::Test1Controller \< ApplicationController  
def index  
@names=Module1::Test1.find(:all)  
end  
end

I have created module1 directory under models and written model as  
follows:  
test1.rb  
class Module1::Test1 \< ActiveRecord::Base  
self.table\_name=‘module1\_test1s’  
end

I have to specify table name in every model, otherwise it looks for  
test1s table only. Is there any way to get rid of this?  
I havent tried implementing association,I think it may create problem in  
that also.

Or is there any cleaner way to do it using rails?

Regards  
Dharmarth
