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 Regards Ritchie On Jan 12, 8:24 am, Curtis Cooley <curtis.coo...@gmail.com> wrote: > I used the "Cleaning Up Controllers with Postback Actions" recipe from > Rails Recipes. Basically you replace all the edit/new/update/create > methods with one method that looks like: > > def edit > @recipe = Recipe.find_by_id(params[:id]) || Recipe.new > if request.post? > @recipe.attributes = params[:recipe] > redirect_to :main_url and return if @recipe.save > end > end > > My form uses form_for with a url parameter: > <% form_for(@schedule, :url => {:action => 'edit'}) do |f| %> > > When I create a new entry and submit the form, it does a POST just > like you'd expect, but when I edit an existing record and submit the > form, the server claims it is doing a PUT. That means no updates since > the record is only updated when the browser submits a POST action. > Even the source in the browser claims the form is going to be > submitted with a POST, but by the time it gets to the server, the > server log claims it is a PUT. Any ideas? I've hacked around it for > now by checking for POST or PUT but that feels, well, hacky. > > Frankly I'm a little disappointed in the recipe. For it to work, > you'll need to change your form and possibly your routes.rb file, but > those details are left out :( > > -- > Curtis Cooley > curtis.coo...@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
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.