Update vehicles_controller.rb

This commit is contained in:
2016-05-11 10:59:44 -04:00
parent 5c9cd88279
commit 7a1d769581

View File

@@ -61,13 +61,17 @@ class VehiclesController < ApplicationController
# update a specific vehicle # update a specific vehicle
def update def update
@customer = params[:customer] @customer = params[:customer]
@vehicle = Vehicle.find_by_id(params[:id]) begin
if @vehicle.update_attributes(params[:vehicle]) @vehicle = Vehicle.find_by_id(params[:id])
flash[:notice] = "Vehicle updated" if @vehicle.update_attributes(params[:vehicle])
redirect_to @vehicle flash[:notice] = "Vehicle updated"
else redirect_to @vehicle
flash[:error] = @vehicle.errors.full_messages.to_sentence if @vehicle.errors else
redirect_to edit_vehicle_path flash[:error] = @vehicle.errors.full_messages.to_sentence if @vehicle.errors
redirect_to edit_vehicle_path
end
rescue ActiveRecord::RecordNotFound
render_404
end end
end end