Class: Admin::TaxonsController
Instance Method Summary
collapse
#find_by_param, #find_by_param!
Instance Method Details
#available ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/admin/taxons_controller.rb', line 23
def available
if params[:q].blank?
@available_taxons = []
else
@available_taxons = Taxon.where('lower(name) LIKE ?', "%#{params[:q].downcase}%")
end
@available_taxons.delete_if { |taxon| @product.taxons.include?(taxon) }
respond_to do |format|
format.js {render :layout => false}
end
end
|
#remove ⇒ Object
36
37
38
39
40
41
|
# File 'app/controllers/admin/taxons_controller.rb', line 36
def remove
@product.taxons.delete(@taxon)
@product.save
@taxons = @product.taxons
render_js_for_destroy
end
|
#select ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'app/controllers/admin/taxons_controller.rb', line 43
def select
@product = Product.find_by_param!(params[:product_id])
@taxon = Taxon.find(params[:id])
@product.taxons << @taxon
@product.save
@taxons = @product.taxons
render :layout => false
end
|
#selected ⇒ Object
19
20
21
|
# File 'app/controllers/admin/taxons_controller.rb', line 19
def selected
@taxons = @product.taxons
end
|