18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/erp_products/shared/product_features_controller.rb', line 18
def get_values
if params[:product_feature_type_id].present?
product_feature_type = ProductFeatureType.find(params[:product_feature_type_id])
if params[:product_features].present?
product_features = []
product_feature_params = params[:product_features].to_a.flatten.delete_if { |o| !o.is_a? Hash }
product_feature_params.each do |product_feature_hash|
product_features << ProductFeature.where('product_feature_type_id = ? and product_feature_value_id = ?',
product_feature_hash['product_feature_type_id'],
product_feature_hash['product_feature_value_id']).first
end
value_ids = ProductFeature.get_values(product_feature_type, product_features)
else
value_ids = ProductFeature.get_values(product_feature_type)
end
else
value_ids = []
end
render :json => {results: value_ids.map { |id| ProductFeatureValue.find(id) }}
end
|