How can I grab all parents in a table, depending on a condition in the
children table ?
Fx.
def list @projects = Project.find(:all)
end
will find all projects in my table. Now let’s say I want show a similar
list, for all open projects… I define an open project, as all lines
(Line has belongs_to :Project) that do not yet have a closed_at
timestamp set.
So basically, I want all projects, where project.line.closed_at is NULL.
Read the documentation for find(). Look at the syntax for the
:conditions parameter.
mich wrote:
Hi,
How can I grab all parents in a table, depending on a condition in the
children table ?
Fx.
def list @projects = Project.find(:all)
end
will find all projects in my table. Now let’s say I want show a similar
list, for all open projects… I define an open project, as all lines
(Line has belongs_to :Project) that do not yet have a closed_at
timestamp set.
So basically, I want all projects, where project.line.closed_at is NULL.
How can I grab all parents in a table, depending on a condition in the
children table ?
Fx.
def list @projects = Project.find(:all)
end
will find all projects in my table. Now let’s say I want show a similar
list, for all open projects… I define an open project, as all lines
(Line has belongs_to :Project) that do not yet have a closed_at
timestamp set.
So basically, I want all projects, where project.line.closed_at is NULL.