I am building a web application using Rails and my first instinct was to make all the controllers RESTful. In particular, I am using the PUT method for any actions that modify data.
But this seems to add unnecessary complexity for a browser-based app because Rails uses Javascript to wrap the URL in a POST request.
Secondly, it means I have to specify the method whenever I create the link for a (non-standard) action. For example, when I have added the “extra” action to the ThingController I need to have the :method => :put
in...
link_to "Action", things_extra_url(thing), :method => :put
Finally, it doesn’t seem very DRY to create this mapping for the additional action in routes.rb...
map.resources :things, :member => { :extra =>:put }
Now I have to think about the definition of the extra
action in two places.
Is resource based routing intended more for building web services APIs than user interface logic? Is it overkill to use it when building a UI front end?
In general I agree with the benefits mentioned in this thread - consistency across controllers is a good thing, and the constraints of REST lead to simple, cleaner designs. I do worry a little that forcing some things into REST might be unnatural.
But I'm not really asking about the design philosophy as much as wondering what folks think about this trade-off in Rails specifically. Do the benefits outweigh the additional complexity?