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?