Class: Kms::Catalog::ProductsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Kms::Catalog::ProductsController
- Defined in:
- app/controllers/kms/catalog/products_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/kms/catalog/products_controller.rb', line 8 def create product_params[:category_ids] = product_params[:category_ids].split(',') if product_params[:category_ids] @product = Product.new(product_params) @product.save render json: @product end |
#destroy ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/kms/catalog/products_controller.rb', line 27 def destroy @product = Product.find(params[:id]) @product.destroy render json: @product end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/kms/catalog/products_controller.rb', line 4 def index render json: Product.order(:name) end |
#show ⇒ Object
22 23 24 25 |
# File 'app/controllers/kms/catalog/products_controller.rb', line 22 def show @product = Product.find(params[:id]) render json: @product end |
#update ⇒ Object
15 16 17 18 19 20 |
# File 'app/controllers/kms/catalog/products_controller.rb', line 15 def update product_params[:category_ids] = product_params[:category_ids].split(',') if product_params[:category_ids] @product = Product.find(params[:id]) @product.update_attributes(product_params) render json: @product end |