Class: Spree::Transit::LocationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/transit/locations_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



16
17
18
19
20
21
22
23
# File 'app/controllers/spree/transit/locations_controller.rb', line 16

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

  load_location

  @search = @locations.ransack(params[:q])
  @collection = @search.result
end

#load_countryObject



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

def load_country
  @countries = Spree::Country.where(id: current_vendor.default_country)
end

#load_locationObject



4
5
6
# File 'app/controllers/spree/transit/locations_controller.rb', line 4

def load_location
  @locations = Spree::State.all
end

#location_after_saveObject



25
26
27
# File 'app/controllers/spree/transit/locations_controller.rb', line 25

def location_after_save
  transit_locations_url
end

#model_classObject



29
30
31
# File 'app/controllers/spree/transit/locations_controller.rb', line 29

def model_class
  Spree::State
end

#newObject



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

def new
  @object.country_id = Spree::Country.find_by(id: current_vendor.default_country)&.id
end

#object_nameObject



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

def object_name
  'state'
end