Class: Admin::ProductsController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::ProductsController
- Defined in:
- app/controllers/admin/products_controller.rb
Instance Method Summary collapse
- #activate ⇒ Object
-
#create ⇒ Object
Create a Product ==== Params * id = ProductParent’s id * product = Hash of Product’s attributes.
-
#destroy ⇒ Object
Destroy a Product ==== Params * id = Product’s id.
- #duplicate ⇒ Object
- #edit ⇒ Object
- #get_cross_selling_id ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_attributes_list ⇒ Object
- #url ⇒ Object
Instance Method Details
#activate ⇒ Object
81 82 83 |
# File 'app/controllers/admin/products_controller.rb', line 81 def activate render :text => @product.activate end |
#create ⇒ Object
Create a Product
Params
-
id = ProductParent’s id
-
product = Hash of Product’s attributes
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/admin/products_controller.rb', line 35 def create if @product.save && manage_dynamic_attributes flash[:notice] = I18n.t('product.create.success').capitalize redirect_to([forgeos_commerce, :edit, :admin, @product]) else flash[:error] = I18n.t('product.create.failed').capitalize render :new end end |
#destroy ⇒ Object
Destroy a Product
Params
-
id = Product’s id
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/admin/products_controller.rb', line 61 def destroy @deleted = @product.deleted? ? @product.destroy : @product.update_attribute(:deleted, true) if @deleted flash[:notice] = I18n.t('product.destroy.success').capitalize else flash[:error] = I18n.t('product.destroy.failed').capitalize end respond_to do |wants| wants.html do redirect_to([forgeos_commerce, :admin, :products]) end wants.js end end |
#duplicate ⇒ Object
26 27 28 29 |
# File 'app/controllers/admin/products_controller.rb', line 26 def duplicate @product = @product.clone render :action => 'new' end |
#edit ⇒ Object
45 46 |
# File 'app/controllers/admin/products_controller.rb', line 45 def edit end |
#get_cross_selling_id ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/admin/products_controller.rb', line 91 def get_cross_selling_id product = Product.find_by_id(params[:product_id]) cross_sellings = product.cross_sellings index = product.cross_sellings.count + 1 cross_selling = Product.find_by_id(params[:cross_selling_id]) cross_sellings.push(cross_selling) if product.update_attributes(:cross_sellings => cross_sellings) render :partial => 'cross_sell_tr', :locals => { :index => index, :pack => product, :product => cross_selling, :_class => params[:class]} end end |
#index ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/admin/products_controller.rb', line 10 def index respond_to do |format| format.html format.json do sort render :layout => false end end end |
#new ⇒ Object
23 24 |
# File 'app/controllers/admin/products_controller.rb', line 23 def new end |
#show ⇒ Object
20 21 |
# File 'app/controllers/admin/products_controller.rb', line 20 def show end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/admin/products_controller.rb', line 48 def update if @product.update_attributes(params[:product]) && manage_dynamic_attributes flash[:notice] = I18n.t('product.update.success').capitalize redirect_to([forgeos_commerce, :edit, :admin, @product]) else flash[:error] = I18n.t('product.update.failed').capitalize render :action => 'edit' end end |
#update_attributes_list ⇒ Object
85 86 87 88 89 |
# File 'app/controllers/admin/products_controller.rb', line 85 def update_attributes_list product_type = ProductType.find_by_id(params[:product_type_id]) product = Product.find_by_id(params[:id]) render :partial => 'attributes', :locals => { :product_type => product_type, :product => product } end |
#url ⇒ Object
77 78 79 |
# File 'app/controllers/admin/products_controller.rb', line 77 def url render :text => Forgeos::url_generator(params[:url]) end |