How can I pass multiple attributes to find_or_create_by in Rails 3?

后端 未结 5 1146
独厮守ぢ
独厮守ぢ 2020-12-12 20:53

I want to use find_or_create_by, but this statement does NOT work. It does not \"find\" or \"create\" with the other attributes.

productproperty = ProductPro         


        
5条回答
  •  甜味超标
    2020-12-12 21:26

    I've found in Rails 3.1 you do not need to pass the attributes in as a hash. You just pass the values themselves.

    ProductProperty.find_or_create_by_product_id_and_property_id_and_value(
      product.id, property.id, d[descname])
    

提交回复
热议问题