Class: Admin::OptionTypesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/option_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#availableObject



7
8
9
10
# File 'app/controllers/admin/option_types_controller.rb', line 7

def available
  set_available_option_types
  render :layout => false
end

#removeObject



16
17
18
19
20
21
# File 'app/controllers/admin/option_types_controller.rb', line 16

def remove
  @product.option_types.delete(@option_type)
  @product.save
  flash.notice = I18n.t("notice_messages.option_type_removed")
  redirect_to selected_admin_product_option_types_url(@product)
end

#selectObject

AJAX method for selecting an existing option type and associating with the current product



40
41
42
43
44
45
46
47
# File 'app/controllers/admin/option_types_controller.rb', line 40

def select
  @product = Product.find_by_param!(params[:product_id])
  product_option_type = ProductOptionType.new(:product => @product, :option_type => OptionType.find(params[:id]))
  product_option_type.save
  @product.reload
  @option_types = @product.option_types
  set_available_option_types
end

#selectedObject



12
13
14
# File 'app/controllers/admin/option_types_controller.rb', line 12

def selected
  @option_types = @product.option_types
end