Class: Spree::Admin::ProductScopesController

Inherits:
BaseController show all
Defined in:
app/controllers/spree/admin/product_scopes_controller.rb

Instance Method Summary collapse

Methods included from Core::ControllerHelpers

included

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/spree/admin/product_scopes_controller.rb', line 8

def create
  @product_group = ProductGroup.find_by_permalink(params[:product_group_id])
  @product_scope = @product_group.product_scopes.build(params[:product_scope])
  if @product_scope.save
    respond_with(@product_scope) do |format|
      format.html { redirect_to edit_admin_product_group_path(@product_group) }
      format.js   { render :layout => false }
    end
  else
    respond_with(@product_scope)
  end
end

#destroyObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/spree/admin/product_scopes_controller.rb', line 21

def destroy
  @product_scope = ProductScope.find(params[:id])
  if @product_scope.destroy
    @product_group = @product_scope.product_group
    @product_group.update_memberships
    respond_with(@product_scope) do |format|
      format.html { redirect_to edit_admin_product_group_path(@product_group) }
      format.js   { render :layout => false }
    end
  else
    respond_with(@product_scope) do |format|
      format.html { redirect_to edit_admin_product_group_path(@product_scope.product_group) }
    end
  end
end