Class: Admin::TaxonsController

Inherits:
BaseController
  • Object
show all
Includes:
Railslove::Plugins::FindByParam::SingletonMethods
Defined in:
app/controllers/admin/taxons_controller.rb

Instance Method Summary collapse

Methods included from Railslove::Plugins::FindByParam::SingletonMethods

#find_by_param, #find_by_param!

Instance Method Details

#availableObject



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

#removeObject



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

#selectObject



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

#selectedObject



19
20
21
# File 'app/controllers/admin/taxons_controller.rb', line 19

def selected
  @taxons = @product.taxons
end