Class: Workarea::Api::Admin::CategoryProductRulesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/admin/category_product_rules_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #sort_direction, #sort_field

Instance Method Details

#createObject



93
94
95
96
97
98
99
100
# File 'app/controllers/workarea/api/admin/category_product_rules_controller.rb', line 93

def create
  @product_rule = @category.product_rules.create!(params[:product_rule])
  respond_with(
    { product_rule: @product_rule },
    { status: :created,
    location: category_product_rules_path(@category.id) }
  )
end

#destroyObject



215
216
217
218
# File 'app/controllers/workarea/api/admin/category_product_rules_controller.rb', line 215

def destroy
  @product_rule.destroy
  head :no_content
end

#indexObject



89
90
91
# File 'app/controllers/workarea/api/admin/category_product_rules_controller.rb', line 89

def index
  respond_with product_rules: @category.product_rules
end

#updateObject



210
211
212
213
# File 'app/controllers/workarea/api/admin/category_product_rules_controller.rb', line 210

def update
  @product_rule.update_attributes!(params[:product_rule])
  respond_with product_rule: @product_rule
end