mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Update vehicles_controller.rb
This commit is contained in:
@@ -41,17 +41,21 @@ class VehiclesController < ApplicationController
|
|||||||
|
|
||||||
# display a specific vehicle
|
# display a specific vehicle
|
||||||
def show
|
def show
|
||||||
|
begin
|
||||||
@vehicle = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
if not @vehicle
|
rescue ActiveRecord::RecordNotFound
|
||||||
flash[:error] = "Vehicle Not Found"
|
render_404
|
||||||
redirect_to :index
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# return an HTML form for editing a vehicle
|
# return an HTML form for editing a vehicle
|
||||||
def edit
|
def edit
|
||||||
|
begin
|
||||||
@vehicle = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
@customers = Customer.all.order(:name)
|
@customers = Customer.all.order(:name)
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# update a specific vehicle
|
# update a specific vehicle
|
||||||
@@ -72,10 +76,10 @@ class VehiclesController < ApplicationController
|
|||||||
begin
|
begin
|
||||||
Vehicle.find_by_id(params[:id]).destroy
|
Vehicle.find_by_id(params[:id]).destroy
|
||||||
flash[:notice] = "Vehicle deleted successfully"
|
flash[:notice] = "Vehicle deleted successfully"
|
||||||
rescue
|
|
||||||
flash[:error] = "No Vehicle Found"
|
|
||||||
end
|
|
||||||
redirect_to action: :index
|
redirect_to action: :index
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user