Combine scoped queries

7 views
Skip to first unread message

Philipp Kursawe

unread,
Jan 17, 2012, 10:27:04 AM1/17/12
to DataMapper
Given these 2 scoped queries it does not seem possible to use
Foo.active.latest

def self.active
(all(:ends_at.gt => Time.now) | all(:ends_at => nil)) &
all(:finished_at => nil)
end

def self.latest
all(:order => [:created_at.desc])
end

It will always return items that are not active. If I reverse the
scopes though and use Foo.latest.active it does indeed return the
expected results.

Is the order important?
Reply all
Reply to author
Forward
0 new messages