On 2 April 2010 21:56, Frederick Cheung <frederick.che...@gmail.com> wrote: > > > On Apr 2, 6:23 pm, dirtbug <nyoun...@gmail.com> wrote: >> I have an update button that doesn't update. Watching the server >> during the attempt, I see: >> >> Processing OrvesController#update (for 128.119.60.171 at 2010-04-02 >> 13:13:29) [PUT] >> Parameters: {"orf"=>nil, "commit"=>"Update", "id"=>"19544"} >> >> orf is my model I'm trying to update in the database. Why is it nil? >> > It's probably worth taking a look at the raw data posted by the > browser - if it is malformed in some way that could be causing rails > to parse it in a funny way. It probably doesn't help that your html is > malformed (a td must be contained in a tr or similar, i'm pretty sure > you can't stick a form in a table like that and the button_to will > create a second form (ie you'll have a form nested in another form) > > Fred
As Fred has pointed out your html is invalid. I find the html validator add-in for firefox excellent as it checks my html as I develop the app, making sure I do not make such errors. Also you can paste your html into the w3c htlm validator (find with google if necessary) to check it. It is a pain that forms cannot be wrapped around table cells but that is the way it is, some browsers will cope with it but it cannot be guaranteed. A form can only wrap a whole table or fit entirely within a cell. Colin >> The view for the page with the update button is called edit.html.erb >> and contains: >> >> <h1>Editing orf</h1> >> <table> >> <% form_for @orf do |f| %></td> >> <td><%= f.error_messages %> >> <td><%= h @orf.locus_tag %></td> >> <td><%= f.text_field 'current_annotation', :size => 50 %></td> >> <td><%= f.submit "Update" %></td> >> <td><%= button_to "Undo last change", :action >> => :undo_last_change, :id => @orf %></td> >> <% end %> >> >> orf's attributes locus_tag and current_annotation are being correctly >> displayed. >> >> Here's the update method: >> >> def update >> @orf = Orf.find(params[:id]) >> if @orf.update_attributes(params[:orf]) >> flash[:notice] = 'Orf was successfully updated.' >> redirect_to orf_path >> else >> flash[:notice] = 'Update failed.' >> redirect_to orf_path >> end >> end >> >> routes.rb contains the line: >> map.resources :orves >> >> No error message appears in the web browser. The update just doesn't >> change anything. >> >> I'm running Rails 2.3.0. >> >> Any idea what I'm doing wrong? > > -- > 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. > > -- 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.