Creating new table entry when updating another entry of another table - Ruby on Rails

Posted by Michaël on Stack Overflow See other posts from Stack Overflow or by Michaël
Published on 2010-06-05T16:55:24Z Indexed on 2010/06/05 17:02 UTC
Read the original article Hit count: 245

Filed under:

Hi,

I have written this code in my "show" view of estimates and I want that, when submitting (update), it creates a new repairs (Repair.new(???)) with some parameters. I don't know where to write the "new repairs" code, in this view or the controller (in update part). I need that the Repair is created one time, not each time the @estimate is updated.

<% form_for @estimate, :url => {:controller => "estimates", :action => "update"} do |f| %>
        <%= f.error_messages %>
            <select id="estimate_accept" name="estimate[accept]">
                <option value="1" selected="selected">accept</option>
                <option value="2">refuse</option>
            </select>
        <%= f.submit "Update" %>
<% end %>

Thank you for your help, I hope my explanations are clear!

© Stack Overflow or respective owner

Related posts about ruby-on-rails