Selecting all Records if Record has any of the ID's from Array

后端 未结 1 1392
北荒
北荒 2021-01-27 15:34

Good Morning Overflow.

I\'m having a problem trying to select all Treatments that have any of the ID\'s stored in an array called @problem.

相关标签:
1条回答
  • 2021-01-27 16:00

    Selecting record by ids array is done with a query:

    Record.where(id: ids)
    

    where ids is ids array. It can be replaced with another query.

    For your case selecting remedies by match name will be as follows:

    ids = Remedy.where("LOWER(remedyName) LIKE ?", name.downcase).pluck(:id)
    
    0 讨论(0)
提交回复
热议问题