Class: Kms::Catalog::PropertiesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Kms::Catalog::PropertiesController
- Defined in:
- app/controllers/kms/catalog/properties_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/kms/catalog/properties_controller.rb', line 11 def create @property = Property.new(property_params.merge(product_id: params[:product_id])) @property.save render json: @property.to_json end |
#destroy ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/kms/catalog/properties_controller.rb', line 23 def destroy @property = Property.find(params[:id]) @property.destroy render json: @property.to_json end |
#index ⇒ Object
5 6 7 8 9 |
# File 'app/controllers/kms/catalog/properties_controller.rb', line 5 def index @product = Product.find_by_id(params[:product_id]) @properties = @product.properties render json: @properties.to_json end |
#tags ⇒ Object
29 30 31 32 |
# File 'app/controllers/kms/catalog/properties_controller.rb', line 29 def @product = Product.find_by_id(params[:product_id]) render json: @product.properties.pluck(:tag).uniq.to_json end |
#update ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/kms/catalog/properties_controller.rb', line 17 def update @property = Property.find(params[:id]) @property.update_attributes(property_params.merge(product_id: params[:product_id])) render json: @property.to_json end |