Booleans in queries?


#1

Hi,

Doing yet another blog engine…

In my db I have defined a boolean ‘published’ field…

not I want to select all published Posts…

Post.find(:all,:conditions=>“published =‘t’”) for sqlite

Post.find(:all,:conditions=>“published !=0”) for mysql…

there has to be a better way??

Mikkel


#2

On 11/28/05, mikkel removed_email_address@domain.invalid wrote:

Post.find(:all,:conditions=>“published !=0”) for mysql…

there has to be a better way??

Mikkel

Post.find :all, :conditions => [‘published = ?’, true]

Just as a light suggestion, try using a published_at date to achieve
this, if you have one in your model already:

Post.find :all, :condtions => ‘published_at IS NULL’


rick
http://techno-weenie.net


#3

thanks a bunch!! did the trick…