def create
customers = params[:tour][:customers_attributes]
params[:tour][:customers_attributes] = {}
@tour = Tour.new(params[:tour])
respond_to do |format|
if @tour.save && @tour.update_customers(customers)
flash[:notice] = 'Tour was successfully created.'
format.html { redirect_to(@tour) }
format.xml { render :xml => @tour, :status => :created, :location => @tour }
else
format.html { render :action => "new" }
format.xml { render :xml => @tour.errors, :status => :unprocessable_entity }
end
end
end
def update
customers = params[:tour][:customers_attributes]
params[:tour][:customers_attributes] = {}
@tour = Tour.find(params[:id])
respond_to do |format|
if @tour.update_attributes(params[:tour]) && @tour.update_customers(customers)
flash[:notice] = 'Tour was successfully updated.'
format.html { redirect_to(@tour) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @tour.errors, :status => :unprocessable_entity }
end
end
end