ruby on rails - Fetch all rows that column_id is in the array of id's, then order by id -


i trying this, not sure if doing correctly:

user.where("region_id => ?", region_ids).order("id asc")  region_ids = [1234,234322,234324,2343,....] 

also, work if region_ids empty (not null, empty)

i seeing error:

check manual corresponds mysql server version right syntax use near '=> null) order id asc' @ line 1: 

when in debugger mode, output region_ids , [].

you're mixing ruby , sql syntax within string. want more ("region_id in (?)", region_ids) or ({ "region_id" => region_ids }).


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -