find_or_initialize_by doesn't work with 2 columns

后端 未结 3 1807
旧时难觅i
旧时难觅i 2021-02-19 22:35

I am trying to insert data in my database using ActiveRecord.

When I use pdays = MyModel.new for initialization rather then the below find_or_initiali

3条回答
  •  天涯浪人
    2021-02-19 23:26

    I read here that in Rails 4, this is the correct syntax:

    Progress.find_or_initialize_by(chore_id: chore.id, period: period[chore.frequency], account_id: chore.account_id)
    

提交回复
热议问题