Class: Spree::Admin::ProductsController

Inherits:
ResourceController show all
Defined in:
app/controllers/spree/admin/products_controller.rb

Instance Attribute Summary

Attributes included from Core::ControllerHelpers

#title

Instance Method Summary collapse

Methods inherited from ResourceController

belongs_to, create, #create, destroy, #edit, #new, new_action, update, #update

Methods included from Core::ControllerHelpers

#associate_user, included, #try_spree_current_user

Instance Method Details

#cloneObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/spree/admin/products_controller.rb', line 34

def clone
  @new = @product.duplicate

  if @new.save
    flash.notice = I18n.t('notice_messages.product_cloned')
  else
    flash.notice = I18n.t('notice_messages.product_not_cloned')
  end

  respond_with(@new) { |format| format.html { redirect_to edit_admin_product_url(@new) } }
end

#destroyObject



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

def destroy
  @product = Product.where(:permalink => params[:id]).first!
  @product.delete

  flash.notice = I18n.t('notice_messages.product_deleted')

  respond_with(@product) do |format|
    format.html { redirect_to collection_url }
    format.js  { render_js_for_destroy }
  end
end

#indexObject



15
16
17
18
19
20
# File 'app/controllers/spree/admin/products_controller.rb', line 15

def index
  respond_with(@collection) do |format|
    format.html
    format.json { render :json => json_data }
  end
end

#showObject



11
12
13
# File 'app/controllers/spree/admin/products_controller.rb', line 11

def show
  redirect_to( :action => :edit )
end