Class: Spree::Transit::VehiclesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/transit/vehicles_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#collection_url, #current_vendor, #edit_object_url, #page, #per_page, #required_vendor_user!, #vendors

Instance Method Details

#collectionObject



24
25
26
27
28
29
30
31
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 24

def collection
  return @collection if defined?(@collection)

  scope

  @search = scope.includes(:vehicle_type).ransack(params[:q])
  @collection = @search.result
end

#editObject



12
13
14
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 12

def edit
  @vehicle = current_vendor.vehicles.find(params[:id])
end

#load_vehicle_typesObject



16
17
18
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 16

def load_vehicle_types
  @vehicle_types = current_vendor.vehicle_types
end

#location_after_saveObject



33
34
35
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 33

def location_after_save
  transit_vehicles_url
end

#model_classObject



37
38
39
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 37

def model_class
  SpreeCmCommissioner::Vehicle
end

#newObject



7
8
9
10
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 7

def new
  @vehicle = SpreeCmCommissioner::Vehicle.new
  super
end

#object_nameObject



41
42
43
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 41

def object_name
  'spree_cm_commissioner_vehicle'
end

#scopeObject



20
21
22
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 20

def scope
  @vehicles = current_vendor.vehicles
end

#set_vendorObject



49
50
51
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 49

def set_vendor
  permitted_resource_params[:vendor] = current_vendor
end

#vehicle_paramsObject



45
46
47
# File 'app/controllers/spree/transit/vehicles_controller.rb', line 45

def vehicle_params
  params.require(:vehicle).permit(:code, :license_plate)
end