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

Instance Method Details

#availableObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/admin/taxons_controller.rb', line 50

def available
  if params[:q].blank?
    @available_taxons = []
  else
    @available_taxons = Taxon.find(:all, :conditions => ['lower(name) LIKE ?', "%#{params[:q].downcase}%"])
  end
  @available_taxons.delete_if { |taxon| @product.taxons.include?(taxon) }
  respond_to do |format|
    format.html
    format.js {render :layout => false}
  end

end

#removeObject



64
65
66
67
68
69
# File 'app/controllers/admin/taxons_controller.rb', line 64

def remove
  @product.taxons.delete(@taxon)
  @product.save
  @taxons = @product.taxons
  render :layout => false
end

#selectObject



71
72
73
74
75
76
77
78
# File 'app/controllers/admin/taxons_controller.rb', line 71

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



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

def selected 
  @taxons = @product.taxons
end