# Naming conventions for models / controllers

**URL:** <https://www.ruby-forum.com/t/naming-conventions-for-models-controllers/176596>\
**Category:** Rails\
**Created:** [October 2, 2009, 8:10pm UTC](https://www.ruby-forum.com/t/naming-conventions-for-models-controllers/176596 "2009-10-02T20:10:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [October 2, 2009, 8:10pm UTC](https://www.ruby-forum.com/t/naming-conventions-for-models-controllers/176596/1 "2009-10-02T20:10:30Z")

</div>

Hi,

this might be a stupid question, but is there like a naming convention  
for base models? Lets say you develop an application where custom work  
is possible. So you create a core for your application.

But for the custom development, you don’t want to touch your core code,  
you want to override / extend it.

How do you achieve this? Is it like possible to name your models /  
controllers in a certain way? And how do you override / extend your base  
code?

I was thing in a way like:

UsersBase \< ActiveRecord::Base =\> (base model for users)  
-\> Users \< UsersBase =\> custom stuff (like extra fields)

UsersBaseController \< ApplicationController =\> (base controller  
-\> UsersController \< UsersBaseController =\> custom actions / overriden  
actions

This could work right? But what in the case that their isn’t any custom  
work? Then I would still need to create those empty models /  
controllers, becouse otherwise I would have diffrent url’s.

Also, I was thinking to convert my base code into plugins. But is still  
something I have to research on how to do that, and how to extend /  
override the plugin code.

So I whas hoping someone could give me some good advice here.  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [October 2, 2009, 8:42pm UTC](https://www.ruby-forum.com/t/naming-conventions-for-models-controllers/176596/2 "2009-10-02T20:42:44Z")

</div>

Michael R. wrote:

> Hi,
> 
> this might be a stupid question, but is there like a naming convention  
> for base models? Lets say you develop an application where custom work  
> is possible. So you create a core for your application.
> 
> But for the custom development, you don’t want to touch your core code,  
> you want to override / extend it.
> 
> How do you achieve this? Is it like possible to name your models /  
> controllers in a certain way? And how do you override / extend your base  
> code?
> 
> I was thing in a way like:
> 
> UsersBase \< ActiveRecord::Base =\> (base model for users)  
> → Users \< UsersBase =\> custom stuff (like extra fields)
> 
> UsersBaseController \< ApplicationController =\> (base controller  
> → UsersController \< UsersBaseController =\> custom actions / overriden  
> actions
> 
> This could work right?

Yes. But it might be better to use namespaces (User::Base and so on).  
Also remember that Rails model names should be singular.

You might want to investigate the use of abstract\_class.

> But what in the case that their isn’t any custom  
> work? Then I would still need to create those empty models /  
> controllers, becouse otherwise I would have diffrent url’s.

Wrong. You could use routing to take care of that.

> Also, I was thinking to convert my base code into plugins. But is still  
> something I have to research on how to do that, and how to extend /  
> override the plugin code.
> 
> So I whas hoping someone could give me some good advice here.  
> Thank you in advance.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [October 2, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/naming-conventions-for-models-controllers/176596/3 "2009-10-02T20:50:02Z")

</div>

Hi Marnen

thanks for the namespace advice. Going to look into that.

Sorry for the mistake about the model names. Has been a long day at the  
office and need a small break 😉

Do you have advice on how do achieve this by modifying application code  
to a plugin?

Thanks
