I am trying this, not sure if I am doing this correctly:
User.where("region_id => ?", region_ids).order("id ASC")
region_ids = [1234,234322,234324,2343,....]
Also, will this work if the region_ids is empty (not null, but empty)
I am seeing an error:
check the manual that corresponds to your MySQL server version for the right syntax to use near '=> NULL) ORDER BY id ASC' at line 1:
When I was in debugger mode, I output the region_ids and it was [].
You’re mixing up Ruby and SQL syntax within the string. What you want is more like
("region_id in (?)", region_ids)or({ "region_id" => region_ids }).