On 6 April 2010 15:25, dirtbug <nyoun...@gmail.com> wrote:
> Fred
>
> Thanks. I took out the whole button_to line, but it still doesn't
> work.  I now have:
> <h1>Editing orf</h1>
> <% form_for @orf do |f| %>
>  <%= f.error_messages %>
>  <%= h @orf.locus_tag %>
>  <%= f.text_field 'current_annotation', :size => 50  %>
>        <%= f.submit "Update" %>
> <% end %>
>
> Still doesn't update.

Can you confirm that the html now validates successfully?  If so then
please post the html for the form and what is seen in the log when the
button is clicked.

Colin

>
> On Apr 5, 6:12 pm, Frederick Cheung <frederick.che...@gmail.com>
> wrote:
>> On Apr 5, 9:46 pm, dirtbug <nyoun...@gmail.com> wrote:
>>
>> > Thanks for the reply. I've now fixed the html (removed the table), but
>> > it didn't fix the problem. The edit view is:
>>
>> You've still got a form nested inside a form (button_to creates a
>> form)
>>
>> Fred
>>
>> > <h1>Editing orf</h1>
>> > <% form_for @orf do |f| %>
>> >   <%= f.error_messages %>
>> >   <%= h @orf.locus_tag %>
>> >   <%= f.text_field 'current_annotation', :size => 50  %>
>> >   <%= f.submit "Update" %>
>> >   <%= button_to "Undo last change", :action => :undo_last_change, :id
>> > => @orf %>
>> > <% end %>
>>
>> > I'm not sure what you mean about taking a look at the raw data posted
>> > by the browser to see if it is malformed. I turned on Firebug and
>> > looked at what it was trying to do when I pressed my "Update" button
>> > and I don't see anything wrong. It shows:
>>
>> > _method put
>> > commit  Update
>> > orf[current_annotation] hypothetical proteinski
>>
>> > That looks OK to me , but I don't really know what I should be looking
>> > for. I was trying to change the current_annotation from hypothetical
>> > protein to hypothetical proteinski, so it looks like it tried.  But
>> > the change doesn't happen.  Any suggestion of how to troubleshoot this
>> > further?
>>
>> > On Apr 2, 4:56 pm, 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
>>
>> > > > 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.

Reply via email to