Class: Spree::Admin::ProductsController

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

Instance Method Summary collapse

Methods inherited from ResourceController

belongs_to, #create, #edit, #new, #update, #update_positions

Methods included from SetsUserLanguageLocaleKey

#set_user_language_locale_key

Instance Method Details

#cloneObject



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

def clone
  @new = @product.duplicate

  if @new.save
    flash[:success] = t('spree.notice_messages.product_cloned')
  else
    flash[:error] = t('spree.notice_messages.product_not_cloned')
  end

  redirect_to edit_admin_product_url(@new)
end

#destroyObject



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

def destroy
  @product = Spree::Product.friendly.find(params[:id])
  @product.discard

  flash[:success] = t('spree.notice_messages.product_deleted')

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

#indexObject



19
20
21
22
# File 'app/controllers/spree/admin/products_controller.rb', line 19

def index
  session[:return_to] = request.url
  respond_with(@collection)
end

#showObject



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

def show
  redirect_to action: :edit
end