Class: CustomAttributes::CustomAttributeValuesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/custom_attributes/custom_attribute_values_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/custom_attributes/custom_attribute_values_controller.rb', line 3

def create
  ca = @owner.custom_attributes.find {|ca| ca.name==params[:name]}

  respond_to do |format| 
    ca.value = params[:value]
    if ca.save
      format.json { render json: ca.to_json(methods: :value), status: :created }
    else
      format.json { render json: ca, status: :unprocessable_entity }
    end
  end
end