Class: Spree::Billing::BaseController
Direct Known Subclasses
AddressesController, AdjustmentsController, BusinessesController, CustomersController, InvoiceController, OptionTypesController, OrdersController, PaymentQrcodesController, PaymentsController, PlacesController, ProductsController, ReportsController, RolesController, StoreCreditsController, SubscriptionsController, UsersController, VariantsController, VendorsController
Instance Method Summary
collapse
#auth_action, #auth_entry, #auth_user, #authorize!, #authorize?, #authorize_admin, #authorize_role!, #redirect_unauthorized_access
Instance Method Details
#collection_url(options = {}) ⇒ Object
73
74
75
76
77
78
79
|
# File 'app/controllers/spree/billing/base_controller.rb', line 73
def collection_url(options = {})
if parent_data.present?
spree.polymorphic_url([:billing, parent, model_class], options)
else
spree.polymorphic_url([:billing, model_class], options)
end
end
|
#current_vendor ⇒ Object
37
38
39
40
41
42
|
# File 'app/controllers/spree/billing/base_controller.rb', line 37
def current_vendor
@current_vendor ||= vendors.find { |v| v[:slug] == session[:billing_current_vendor_slug] } || vendors.first
session[:billing_current_vendor_slug] ||= @current_vendor&.slug
@current_vendor
end
|
#default_url_options(options = {}) ⇒ Object
19
20
21
|
# File 'app/controllers/spree/billing/base_controller.rb', line 19
def default_url_options(options = {})
{ locale: I18n.locale }.merge(options)
end
|
#edit_object_url(object, options = {}) ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'app/controllers/spree/billing/base_controller.rb', line 63
def edit_object_url(object, options = {})
if parent_data.present?
spree.send "edit_billing_#{resource.model_name}_#{resource.object_name}_url",
parent, object, options
else
spree.send "edit_billing_#{resource.object_name}_url", object, options
end
end
|
#handle_unauthorized_vendor ⇒ Object
23
24
25
|
# File 'app/controllers/spree/billing/base_controller.rb', line 23
def handle_unauthorized_vendor
redirect_to billing_forbidden_url
end
|
#page ⇒ Object
44
45
46
|
# File 'app/controllers/spree/billing/base_controller.rb', line 44
def page
params[:page] || 1
end
|
#per_page ⇒ Object
48
49
50
|
# File 'app/controllers/spree/billing/base_controller.rb', line 48
def per_page
params[:per_page] || 25
end
|
#required_vendor_user! ⇒ Object
#set_locale ⇒ Object
15
16
17
|
# File 'app/controllers/spree/billing/base_controller.rb', line 15
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
|
#switch_vendor ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'app/controllers/spree/billing/base_controller.rb', line 53
def switch_vendor
head :unprocessable_entity if request.xhr?
exists = vendors.find { |v| v[:slug] == params[:slug] }
session[:billing_current_vendor_slug] = params[:slug] if exists
head exists ? :ok : :not_found
end
|
#vendors ⇒ Object
33
34
35
|
# File 'app/controllers/spree/billing/base_controller.rb', line 33
def vendors
@vendors ||= spree_current_user.vendors.to_a
end
|