The user model has a field called locations of datatype 'text'. I save parsed json string inside this field. For example "[\"3\",\"7\"]"(basically an array of locations) . I want to make a query on this field. I want to collect the users who belong to a particular location. For example when I pass in 3, I want users record who have them in their "locations" field. Is it possible to achieve in a single query? Or any other logic to achieve this is also welcome.
users table
ID locations
1 "[\"3\",\"6\"]"
2 "[\"3\",\"7\"]"
3 "[\"4\",\"7\"]"
I use Rails version '3.2.22' and ruby '1.9.3'
Aucun commentaire:
Enregistrer un commentaire