Naming conventions for models / controllers

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.

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
[email protected]

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 :wink:

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

Thanks