Class: SolidusFriendlyPromotions::Admin::BaseController
- Inherits:
-
Spree::Admin::ResourceController
- Object
- Spree::Admin::ResourceController
- SolidusFriendlyPromotions::Admin::BaseController
show all
- Defined in:
- app/controllers/solidus_friendly_promotions/admin/base_controller.rb
Instance Method Summary
collapse
Instance Method Details
#collection_url(options = {}) ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 41
def collection_url(options = {})
if parent?
routes_proxy.polymorphic_url([:admin, parent, model_class], options)
else
routes_proxy.polymorphic_url([:admin, model_class], options)
end
end
|
#edit_object_url(object, options = {}) ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 23
def edit_object_url(object, options = {})
if parent?
routes_proxy.polymorphic_url([:edit, :admin, parent, object], options)
else
routes_proxy.polymorphic_url([:edit, :admin, object], options)
end
end
|
#new_object_url(options = {}) ⇒ Object
15
16
17
18
19
20
21
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 15
def new_object_url(options = {})
if parent?
routes_proxy.new_polymorphic_url([:admin, parent, model_class], options)
else
routes_proxy.new_polymorphic_url([:admin, model_class], options)
end
end
|
#object_url(object = nil, options = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 31
def object_url(object = nil, options = {})
target = object || @object
if parent?
routes_proxy.polymorphic_url([:admin, parent, target], options)
else
routes_proxy.polymorphic_url([:admin, target], options)
end
end
|
#parent ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 6
def parent
@parent ||= self.class.parent_data[:model_class]
.includes(self.class.parent_data[:includes])
.find_by!(self.class.parent_data[:find_by] => params["#{parent_model_name}_id"])
instance_variable_set(:"@#{parent_model_name}", @parent)
rescue ActiveRecord::RecordNotFound => e
resource_not_found(flash_class: e.model.constantize, redirect_url: routes_proxy.polymorphic_url([:admin, parent_model_name.pluralize.to_sym]))
end
|
#parent_model_name ⇒ Object
53
54
55
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 53
def parent_model_name
self.class.parent_data[:model_name].gsub("solidus_friendly_promotions/", "")
end
|
#routes_proxy ⇒ Object
49
50
51
|
# File 'app/controllers/solidus_friendly_promotions/admin/base_controller.rb', line 49
def routes_proxy
solidus_friendly_promotions
end
|