Class: Spree::Admin::VendorKindOptionTypesController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/admin/vendor_kind_option_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#collection_url(options = {}) ⇒ Object



46
47
48
# File 'app/controllers/spree/admin/vendor_kind_option_types_controller.rb', line 46

def collection_url(options = {})
  admin_vendor_vendor_kind_option_types_url(options)
end

#indexObject



14
15
16
# File 'app/controllers/spree/admin/vendor_kind_option_types_controller.rb', line 14

def index
  @vendor_kind_option_types = @vendor.vendor_kind_option_types
end

#load_resourceObject



7
8
9
10
11
# File 'app/controllers/spree/admin/vendor_kind_option_types_controller.rb', line 7

def load_resource
  @vendor ||= Spree::Vendor.find_by(slug: params[:vendor_id])
  @vendor ||= Spree::Vendor.find_by(id: params[:vendor_id])
  @object ||= @vendor
end

#model_classObject



36
37
38
# File 'app/controllers/spree/admin/vendor_kind_option_types_controller.rb', line 36

def model_class
  Spree::Vendor
end

#object_nameObject



41
42
43
# File 'app/controllers/spree/admin/vendor_kind_option_types_controller.rb', line 41

def object_name
  'vendor'
end

#permitted_resource_paramsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/spree/admin/vendor_kind_option_types_controller.rb', line 19

def permitted_resource_params
  option_values = []
  selected_option_value_vendors_ids = params[object_name]['selected_option_value_vendors_ids']

  selected_option_value_vendors_ids.each do |option_value_id|
    option_value_id = option_value_id.to_i

    unless option_value_id.zero?
      option_value = Spree::OptionValue.find(option_value_id)
      option_values << option_value unless option_value.nil?
    end
  end

  { vendor_kind_option_values: option_values }
end