Tuesday, January 12, 2010

Re: [Rails] Re: Weird POST/PUT behavior

On Mon, Jan 11, 2010 at 9:57 PM, Ritchie <ritchiey@gmail.com> wrote:
> I haven't looked at the recipe you refer to but most browsers will
> only do posts. That's why Rails form helpers simulate doing a put by
> adding a hidden field called _method to the form which rails then
> checks for before passing control onto your controller.
>
> PUTs *are* supposed to be used to update your records but the RESTful
> way of doing it is to put the update code in the update method and
> specifying resources in your routes.rb file.
>
> Also using the REST convention, your edit method should respond to a
> GET and should display a form. It shouldn't be updating anything.
>
> This guide should set you on the right track: http://guides.rubyonrails.org/getting_started.html
>

Ok, so the recipe allows you to replace 4 similar methods with one
method, which is more DRY, but from what Ritchie is saying, adhering
to the RESTful interface is more important.

Is it 'better' to keep the four methods and DRY them up as best I can
rather than trying the post back method recipe? I'm thinking so, since
the post back recipe made me do some things I didn't really like, like
removing the resources entry from my routes. And it broke things.

Plus, I just discovered that the "Rails Recipes" book is for Rails
1.0. Sheesh, I just bought it :(

Perhaps the post back model isn't encouraged any more despite it's DRYness.
--
Curtis Cooley
curtis.cooley@gmail.com
home:http://curtiscooley.com
blog:http://ponderingobjectorienteddesign.blogspot.com
===============
Leadership is a potent combination of strategy and character. But if
you must be without one, be without the strategy.
-- H. Norman Schwarzkopf

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate