I am using find_by_sql for this query, and it iss returning an array.
I want to do something like Job.hongkong_jobs.where(status: true) but I can't because it is an array.
scope :hongkong_jobs, -> { find_by_sql "SELECT DISTINCT(jobs.*) FROM" + Task.near([22.275754, 114.163056], 35.17936816723013, :units => :km).joins(:job).where(jobs: {status: [:open,:new]}).to_sql.split("FROM").last.split("ORDER").first + "ORDER BY start_at ASC" }
So my question is : how can I convert it into an active record object so I can do .where within this scope?
I tried with Job.where(aray.map(&:id)), and it's not working for me.
My solution is:
Job.where(id: array.map(&:id))
This works.
Cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With