# RESTful controllers... seriously?

**URL:** <https://www.ruby-forum.com/t/restful-controllers-seriously/139245>\
**Category:** Rails\
**Created:** [June 2, 2008, 9:14am UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245 "2008-06-02T09:14:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 2, 2008, 9:14am UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245/1 "2008-06-02T09:14:31Z")

</div>

I’m in an argument with a developer I’m working with. We’re developing  
an app with no API and quite a bit of AJAX. He wants to use restful  
controllers everywhere. This annoys me. Right now we have one page  
that is referencing 4 different restful controllers with views and  
partials all over the place. To me it makes more sense to put all the  
actions you need for one page into one controller so it’s coherent and  
easy to debug. I think it could just be that his nazi perspective on  
mapping controllers directly to models could be the problem… I’ve  
read some different stuff about restful, but I haven’t been able to  
find anything that’s a simple clear explanation of WHEN and WHY to use  
them?

Who here is the jackass? 🙂

John

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 2, 2008, 10:44am UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245/2 "2008-06-02T10:44:20Z")

</div>

Ok, let’s start with the fact, that there is no perfct way and much may  
depend on details of your app.

> To me it makes more sense to put all the  
> actions you need for one page into one controller so it’s coherent and  
> easy to debug.

Nope, this would maybe make sense, if you could be 100% sure, that those  
actions will never be used in any other view. Otherwise the mapping  
model/controller is much more likely to be still helpful if your app  
grows and gets more complex.

Think you have a show action for whatever model (say a product as  
axample). As long as there is only one central page that shows this  
resource, you will find it in the controller where you expect it. But if  
you add more views and allow to display this product from different  
places in your app, you’ll start searching for your action. With model  
based REST resources the show action for the product will be in the  
products controller.

And this way to see things is more object oriented. You have a resource  
and somehow ask this resource to display itself, update itselft and so  
on.

As mentioned, there may be lots of examples to show cases where your  
view may be better, but in general REST is right…

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 2, 2008, 11:38am UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245/3 "2008-06-02T11:38:59Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Monday 02 June 2008 04:54:44 John wrote:

> He wants to use restful  
> controllers everywhere. This annoys me. Right now we have one page  
> that is referencing 4 different restful controllers with views and  
> partials all over the place. To me it makes more sense to put all the  
> actions you need for one page into one controller so it’s coherent  
> and easy to debug.

Sounds like your colleague has collapsed two ideas into one. REST isn’t  
the same thing as CRUD, although having your CRUD-centric controllers  
and actions be RESTful is popoular in the Rails community.

Ciao,  
Sheldon.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIQ79tpGJX8XSgas0RAq7zAKCwDCehpDHHBTl9trn7kFD8XgBHQgCfZ+OC  
SI3QXVW6CsyQd9O9OY3HxX4=  
=NFbP  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 2, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245/4 "2008-06-02T17:00:56Z")

</div>

Luke, I’m your father, Give in to the Rest side of the force …

I heard this same kind of argument at a Restful session at Railsconf  
on Saturday at the guy that was arguing your point was generally  
declared to be half horse and half donkey, if that answers the last  
question. There is never a complete right and wrong and Rest can be  
done poorly, but using Rest is always more correct than what you are  
suggesting. It’s change, It’s painful. You are not used to it. You are  
resisting the correct thing. Your argument is similar to arguing  
against OO because it is new and painful.  
Get over it, go with Rest, Learn about it and do it correctly.

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 2, 2008, 5:45pm UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245/5 "2008-06-02T17:45:29Z")

</div>

> I hope you’re responding to the original post, not my reply. 🙂

No,  
I was responding to the first post. I concur fully with your thoughts  
(as if anyone cares what I think)

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 2, 2008, 5:08pm UTC](https://www.ruby-forum.com/t/restful-controllers-seriously/139245/6 "2008-06-02T17:08:37Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Monday 02 June 2008 16:59:54 Ruby F. wrote:

> Your argument is similar to arguing  
> against OO because it is new and painful.  
> Get over it, go with Rest, Learn about it and do it correctly.

I hope you’re responding to the original post, not my reply. 🙂

If not, I wasn’t arguing against REST. I was pointing out that people  
often assume that REST and CRUD-centricity are the same thing.

What I assumed to be implicit in my post, but perhaps should have made  
explicit, is that REST always makes a great deal of sense, but  
CRUD-centricity does not.

Ciao,  
Sheldon.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIRAy6pGJX8XSgas0RAuQzAJ9qdHBhaAUF3aK753SiPjCSVOGDVACgshqR  
P7O+QQwzQ/0gPCOkuaygAO4=  
=jljY  
-----END PGP SIGNATURE-----
