Class: Spree::Transit::RoutesController
Instance Method Summary
collapse
#collection_url, #current_vendor, #edit_object_url, #page, #per_page, #required_vendor_user!, #vendors
Instance Method Details
#collection ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 26
def collection
return @collection if defined?(@collection)
params[:q] ||= {}
params[:q][:deleted_at_null] ||= '1'
params[:q][:s] ||= 'updated_at desc'
current_vendor.products.where(product_type: :transit)
@search = current_vendor.products.where(product_type: :transit).ransack(params[:q].reject { |k, _v| k.to_s == 'deleted_at_null' })
@collection = @search.result
.page(params[:page])
.per(params[:per_page] || Spree::Backend::Config[:variants_per_page])
@collection
end
|
#find_resource ⇒ Object
45
46
47
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 45
def find_resource
product_scope.with_deleted.friendly.find(params[:id])
end
|
#load_data ⇒ Object
14
15
16
17
18
19
20
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 14
def load_data
@product ||= model_class.find_by(id: params[:id])
@option_types = OptionType.order(:name)
@shipping_categories = ShippingCategory.order(:name)
@selected_option_type_ids = Spree::OptionType.where(name: %w[origin destination]).ids
@taxons = Spree::Taxonomy.place.taxons
end
|
#location_after_save ⇒ Object
53
54
55
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 53
def location_after_save
transit_routes_url
end
|
#model_class ⇒ Object
57
58
59
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 57
def model_class
Spree::Product
end
|
#new ⇒ Object
22
23
24
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 22
def new
@object.product_type = :transit
end
|
#object_name ⇒ Object
61
62
63
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 61
def object_name
'product'
end
|
#product_scope ⇒ Object
49
50
51
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 49
def product_scope
current_store.products.accessible_by(current_ability, :index)
end
|
#scope ⇒ Object
6
7
8
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 6
def scope
current_vendor.products.where(product_type: :transit)
end
|
#show ⇒ Object
10
11
12
|
# File 'app/controllers/spree/transit/routes_controller.rb', line 10
def show
redirect_to spree.edit_transit_route_path(@object)
end
|