# MVC Best Foot Forwarded

**URL:** <https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901>\
**Category:** Rails\
**Created:** [February 26, 2007, 8:03pm UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901 "2007-02-26T20:03:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![acgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@acgreen](https://www.ruby-forum.com/u/acgreen)\
**Post date:** [February 26, 2007, 8:03pm UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901/1 "2007-02-26T20:03:45Z")

</div>

I’d like to know the best way forward with regards to Rails and MVC.  
This is really concerning the controller.

I have a ‘register’ controller which allows a company to register with  
the site. Once registered, they go into a backend where they can add  
employees, activities etc.

At the moment, these are all handled by the ‘register’ controller but to  
me, it’s heading the wrong way.

Each object has it’s own model for example Company, Employee, Activity,  
Qualification.

my register controller is now going along these lines with regards to  
actions … add\_employee, update\_employee, add\_activity,  
update\_activity etc.

Does that make sense or in this case, should each object have a  
controller called from the main menu ‘register.rhtml’ such as

link\_to ‘My Emplyees’, :controller =\> ‘employee’, :action =\> ‘do\_sth’  
link\_to ‘My Activities’, :controller =\> ‘activity’, :action =\> ‘do\_sth’

CIA

-Ants

* * *

What kind of emailer are you? Find out today - get a free analysis of  
your email personality. Take the quiz at the Yahoo! Mail Championship.

---

<div class="post-metadata">

**Author:** ![acgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@acgreen](https://www.ruby-forum.com/u/acgreen)\
**Post date:** [February 26, 2007, 8:16pm UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901/2 "2007-02-26T20:16:48Z")

</div>

I would definitely go with the latter.  
Also, I would take a look at any of the numerous blog entries that are  
cropping up regarding Rails and REST… it’s a style of designing  
controllers/models that might make sense to you, given the kind of site  
you’re building.

I also might think about, even if you don’t go with rest, abstracting  
the  
register controller to be an action of a different controller.  
You might have several administrative tasks that are associated with an  
overal business… updating business info, maybe adding or removing  
admin  
users to their business account… you may want to make a controller  
that  
contains functions pertaining to overall business activities, and make  
register an action of that controller.

I would compare this to something like having a regular user  
login/logout  
type of situation.  
Instead of having a register controller for when a new user signs up,  
you  
might want to have a User controller with a register action, a login  
action,  
a logout action, an edit action, etc. Again, this lends itself to REST,  
so  
definitely read up on that.

---

<div class="post-metadata">

**Author:** ![acgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@acgreen](https://www.ruby-forum.com/u/acgreen)\
**Post date:** [February 27, 2007, 1:59am UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901/3 "2007-02-27T01:59:40Z")

</div>

If you are using Rails 1.1.6 then spagetti code will result. If you  
are using Rails 1.2.2 to build a RESTful app, then your design becomes  
clean when you embrace the RESTful design concepts.

All registration activities will be handled by RegistrationController,  
employee management by EmployeeController and so on.

---

<div class="post-metadata">

**Author:** ![acgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@acgreen](https://www.ruby-forum.com/u/acgreen)\
**Post date:** [February 27, 2007, 2:49pm UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901/4 "2007-02-27T14:49:53Z")

</div>

Yeah, have been thinking about this and was also wondering about the  
controller noun / verb thing. So, that’s clearer 😉

The way forward now looks like being something like UserContoller (for  
the company) and controllers for EmployeeController etc. After  
registration, go to UserAdminController which will link to the other  
contollers.

What d’ya think of that?! Cleaner … correct?

Thanks for replying and taking an interest, too. As a developer, setting  
things up is the hardest part, the actual work isn’t a problem. But if  
the design isn’t intuitive from the beginning then it’s just plain  
wrong!!

Luke I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Actually, if he were building a  
restful app, I would imagine registration would, as I said, become a  
member of other controllers… REST generally implies that the  
controllers be nouns, not verbs, and that verbs be the actions of the  
controllers.

On 2/26/07, Bala P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
If you are using Rails 1.1.6 then spagetti code will result. If you  
are using Rails 1.2.2 to build a RESTful app, then your design becomes  
clean when you embrace the RESTful design concepts.

All registration activities will be handled by RegistrationController,  
employee management by EmployeeController and so on.

On 2/26/07, Anthony G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d like to know the best way forward with regards to Rails and MVC. This is  
> really concerning the controller.

* * *

New Yahoo! Mail is the ultimate force in competitive emailing. Find out  
more at the Yahoo! Mail Championships. Plus: play games and win prizes.

---

<div class="post-metadata">

**Author:** ![acgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@acgreen](https://www.ruby-forum.com/u/acgreen)\
**Post date:** [February 27, 2007, 3:21pm UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901/5 "2007-02-27T15:21:58Z")

</div>

On 2/27/07, Anthony G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yeah, have been thinking about this and was also wondering about the  
> controller noun / verb thing. So, that’s clearer 😉
> 
> The way forward now looks like being something like UserContoller (for the  
> company) and controllers for EmployeeController etc. After registration, go  
> to UserAdminController which will link to the other contollers.
> 
> What d’ya think of that?! Cleaner … correct?

The UserAdmin thing remains somewhat of a bone of contention in a lot of  
communities… it seems as though that’s a fairly good way to structure  
it,  
but if you’re going pure REST, then probably it isn’t: a controller name  
should imply the noun on which it’s verb actions take place, and in this  
case, you’re not performing an action on “a useradmin”… but  
meta-controllers are a fact of life when it comes to doing any kind of  
decent sized web app.

That being said, in your particular case I think you might be able to do  
something like having a different layout depending on whether or not  
someone  
is logged in, with the logged in layout having a menu bar with links to  
the  
various controllers, so you can get from any controller to any other  
controller without having to use the meta-controller.

Thanks for replying and taking an interest, too. As a developer, setting

> things up is the hardest part, the actual work isn’t a problem. But if the  
> design isn’t intuitive from the beginning then it’s just plain wrong!!
> 
> \*\*

You’re welcome, I agree, and damn right.

---

<div class="post-metadata">

**Author:** ![acgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@acgreen](https://www.ruby-forum.com/u/acgreen)\
**Post date:** [February 27, 2007, 1:43pm UTC](https://www.ruby-forum.com/t/mvc-best-foot-forwarded/86901/6 "2007-02-27T13:43:44Z")

</div>

Actually, if he were building a restful app, I would imagine  
registration  
would, as I said, become a member of other controllers… REST generally  
implies that the controllers be nouns, not verbs, and that verbs be the  
actions of the controllers.
