I'm trying to convert a non-sql application (4D or 4th Dimension) to
rails. Got all the CRUD stuff down, but I'm running into problem in
generating reports. 4D makes heavy use of Sets and Selections, which
are really just an array of record numbers that can be used to quickly
restore a query. Those arrays make aggregate reporting fairly easy. I
can get there using an sql query. I'm just looking for the best
approach using rails.
Lets say I have a simple has_many, belong_to relation:
Project:ARB (project fields :id, :name, "status, ...)
Task:ARB (task fields :id, :project_id, :name, :date_due, ...)
I need to go both ways
give me a list of tasks where the project status is active, or:
select * from tasks where project_id in (select id from projects
where status = 'Active')
give me a list of projects where the task date_due is < some_date
select * from projects where id in (select project_id from tasks
where date_due < '2009-09-09'
How do I do that in an ActiveRecord find?