Skip to content

Instantly share code, notes, and snippets.

Created June 12, 2013 03:40
Show Gist options
  • Save anonymous/5762672 to your computer and use it in GitHub Desktop.
Save anonymous/5762672 to your computer and use it in GitHub Desktop.
def edit_measurements
@estimate = Estimate.find(params[:id])
@measurements = @estimate.measurements
end
def update_measurements
#Find object using form parameters
@estimate = Estimate.find(params[:id])
#Update subject
if @estimate.update_attributes(params[:estimate])
#if save succeeds, redirect to list action
redirect_to(:action => 'list_current')
else
#if save fails, redisplay form to user can fix problems
render('edit')
end
end
<div>
<h2>Measurements For: <%= @estimate.project.name %></h2>
<%= form_for @estimate, :url => {:action => 'update_measurements', :id => @estimate.id} do |f| %>
<table summary="Lead detail view">
<%= f.fields_for :measurements do |m| %>
<tr>
<th><%= m.text_field(:name) %></th>
<td><%= m.text_field(:amount) %>
</tr>
<% end %>
</table>
<%= f.submit "Submit" %>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment