Class: Kms::Catalog::PropertiesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/kms/catalog/properties_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#indexObject



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

#tagsObject



29
30
31
32
# File 'app/controllers/kms/catalog/properties_controller.rb', line 29

def tags
  @product = Product.find_by_id(params[:product_id])
  render json: @product.properties.pluck(:tag).uniq.to_json
end

#updateObject



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