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



51
52
53
54
55
56
57
58
# File 'app/controllers/admin/option_types_controller.rb', line 51

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

#update_positionsObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/admin/option_types_controller.rb', line 23

def update_positions
  params[:positions].each do |id, index|
    OptionType.update_all(['position=?', index], ['id=?', id])
  end
  
  respond_to do |format|
    format.html { redirect_to admin_product_variants_url(params[:product_id]) }
    format.js  { render :text => 'Ok' }
  end
end