Hi,

I am pretty new to ror...
I create a table filled thanks to a partial with a collection.
Each line is a "form_for" ending with a submit which update some
values for a specific row.
My problem is that I would like, after clicking on the submit button
that, the concerned row and only this one updates and not the whole
table. With the following code, it update well, but at the end at only
view the modified row (loosing application layout, table view...)

Can someone help me ?

I have the following views :

--------- views/home/index.html.erb

<% content_for :content do %>
  <h1><%= @group.name %></h1>
    <table>

       <!-- Headers -->
      <tr>
        <th>Cars</th>
        <% @group.checks.each do |c| %>
          <th><%= c.name %></th>
        <% end %>
      </tr>

      <!-- Values -->
      <%= render :partial => "cars", :collection => @group.cars%>
    </table>

    <%= link_to 'Add car', new_car_path %>
<% end %>

--------- views/home/_car.html.erb
<tr>
  <% form_for car, :url => { :action => "update_car_checks" } do |f|
%>
    <td><%= car.name %></td>
    <%= hidden_field_tag :car_id, car.id %>
    <% car.group.checks.each do |c| %>
      <td><%= text_field_tag 'check_' + c.id.to_s, car.check_at
(c.id), :size => 1 %></td>
    <% end %>
    <td><%= f.submit 'Record' %></td>
    <% end %>
</tr>

Then, in home controller :
--------- controllers/home_controller.rb
def update_car_checks
  @car = Car.find(params[:car_id])

  #... Some updates and check for the car...

  render :partial => "car"
end

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to