here…is the essential
def edit
@booking = Booking.new
@project = Project.find(params[:id])
@partprojects = Project.find_all_by_parent_id(@project.id)
@bookings = Booking.zwischen(start, ende)
@main_hours = main_hours_sum(@project.id)
@part_hours = part_hours_sum(@partprojects.id)
@all_hours = @main_hours + @part_hours
end
form
<%= simple_form_for @booking, :url => booking_path, :remote => true, :method => :put do %>
<% @bookings.each do |booking|%>
<%= fields_for “booking”, booking do |f|%>
<%= f.text_field :hour, :class => ‘submittable’ %>
<%= hidden_field_tag “booking_ids”, booking.id %>
<% end %>
<% end %>
coffee
$(“.submittable”).live “change”, →
$(this).parents(“form:first”).submit()
def update
if params[:booking_ids]
params[:booking_ids].each do
Booking.update(params[:booking].keys, params[:booking].values).reject { |p| p.errors.empty? }
end
end
respond_to do |format|
format.js{
@project = Project.find(params[:id])
@main_hours = main_hours_sum(@project.id)
}
end
end