Reputation: 2174
I want to ensure that only Movies with a watched date are brought back and ordered by that value in ascending order.
I think I'm fairly close with the following:
default_scope :conditions => { :watched_date => not null },
:order => 'watched_date ASC'
But I don't know how to add a condition for a non-null date.
Upvotes: 1
Views: 660
Reputation: 51697
Does it work if you change the conditions to this?:
:conditions => 'watched_date IS NOT NULL'
You might want to include the table name incase this is used in joins like so:
:conditions => 'movies.watched_date IS NOT NULL'
Upvotes: 2