mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Added comments to clearify methods
This commit is contained in:
@@ -11,11 +11,11 @@
|
|||||||
# This controller class will handle map management
|
# This controller class will handle map management
|
||||||
class VehiclesController < ApplicationController
|
class VehiclesController < ApplicationController
|
||||||
unloadable
|
unloadable
|
||||||
|
|
||||||
include AuthHelper
|
include AuthHelper
|
||||||
|
|
||||||
before_filter :require_user
|
before_filter :require_user
|
||||||
|
|
||||||
# display a list of all vehicles
|
# display a list of all vehicles
|
||||||
def index
|
def index
|
||||||
if params[:customer_id]
|
if params[:customer_id]
|
||||||
@@ -25,7 +25,8 @@ class VehiclesController < ApplicationController
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# search for a vehicle by vin
|
||||||
if params[:search]
|
if params[:search]
|
||||||
@vehicles = Vehicle.search(params[:search]).paginate(:page => params[:page])
|
@vehicles = Vehicle.search(params[:search]).paginate(:page => params[:page])
|
||||||
if only_one_non_zero?(@vehicles)
|
if only_one_non_zero?(@vehicles)
|
||||||
@@ -47,11 +48,11 @@ class VehiclesController < ApplicationController
|
|||||||
flash[:notice] = "New Vehicle Created"
|
flash[:notice] = "New Vehicle Created"
|
||||||
redirect_to @vehicle
|
redirect_to @vehicle
|
||||||
else
|
else
|
||||||
flash[:error] = @vehicle.errors.full_messages.to_sentence
|
flash[:error] = @vehicle.errors.full_messages.to_sentence
|
||||||
redirect_to Vehicle.find_by_vin @vehicle.vin
|
redirect_to Vehicle.find_by_vin @vehicle.vin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# display a specific vehicle
|
# display a specific vehicle
|
||||||
def show
|
def show
|
||||||
begin
|
begin
|
||||||
@@ -61,7 +62,7 @@ class VehiclesController < ApplicationController
|
|||||||
render_404
|
render_404
|
||||||
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
|
begin
|
||||||
@@ -71,11 +72,11 @@ class VehiclesController < ApplicationController
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# update a specific vehicle
|
# update a specific vehicle
|
||||||
def update
|
def update
|
||||||
@customer = params[:customer]
|
@customer = params[:customer]
|
||||||
begin
|
begin
|
||||||
@vehicle = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
if @vehicle.update_attributes(params[:vehicle])
|
if @vehicle.update_attributes(params[:vehicle])
|
||||||
flash[:notice] = "Vehicle updated"
|
flash[:notice] = "Vehicle updated"
|
||||||
@@ -88,7 +89,7 @@ class VehiclesController < ApplicationController
|
|||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# delete a specific vehicle
|
# delete a specific vehicle
|
||||||
def destroy
|
def destroy
|
||||||
@@ -100,9 +101,11 @@ class VehiclesController < ApplicationController
|
|||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# checks to see if there is only one item in an array
|
||||||
|
# @return true if array only has one item
|
||||||
def only_one_non_zero?( array )
|
def only_one_non_zero?( array )
|
||||||
found_non_zero = false
|
found_non_zero = false
|
||||||
array.each do |val|
|
array.each do |val|
|
||||||
|
|||||||
Reference in New Issue
Block a user