I have a model with a string attribute, the attribute can have values 'abc', 'def', 'ghi' or 'jkl' + count I need to get all records with the value 'jkl' + count. I was hoping something like:
Model.where(status[0..2]: 'jkl')
Would work, but it seems like it doesn't, is there a good way for me to do this?
答案 0 :(得分:2)
You can use LIKE query with wildcards
Model.where('status LIKE ?', 'ijk%')