Jim Burgess wrote in post #968051: > Cheers for the explanation, Fred. > Following your advice I passed the appropriate HTTP method to the form > in the partial and now everything works as it should. > > In case it helps anyone else, I now have: > > new.html.erb: > <%= render :partial => "form", :locals => {:url => {:action => > "create"}, :method => :post} %> > > edit.html.erb: > <%= render :partial => "form", :locals => {:url => {:action => "update", > :id => @flight}, :method => :put} %> > > _form.html.erb: > <% form_for :flight, :url => url, :html=>{:method=> method} do |f| %>
But you missed Fred's point entirely: you don't need to do that! Rails will test @flight.new_record? and pick the method accordingly. So all you need in both new.html.erb and edit.html.erb is render :partial => 'form' and in _form.html.erb, just form_for @flight You're reinventing what Rails already does for you. > > Thanks again. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- Posted via http://www.ruby-forum.com/. -- 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.