Re: Boolean circles..

Rob Biedenharn
Fri, 07 Mar 2008 12:15:39 -0000

On Mar 7, 2008, at 7:00 AM, Fredrik Karlsson wrote:
> Hi,
>
> This is just kindof a RoR question, but since you all potentially do
> the same things as I do, I thought I''ll ask here..
>
> Im trying to use the boolean type in the database. Migrations is no
> problem, it even converts the 0/1 values from my import CSV to false
> and true.
> However, I cannot make the :conditions part of a find work:
>
> Loading development environment (Rails 2.0.2)
>>> c = Club.find(1)
> => #<Club id: 1, club_name: "Ume\214 Kuniba kai", logo:
nil,
> currently_active: 1, created_at: "2008-03-07 12:52:35",
updated_at:
> "2008-03-07 12:52:35">
>>> m = c.members.find(:first, :conditions => "is_active =
1")
> => nil
>>> m = c.members.find(:first, :conditions => "is_active =
true")
> ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
> true: SELECT * FROM members   WHERE (members.club_id = 1 AND
> (is_active = true))  LIMIT 1


Have you tried:
   :conditions => [''is_active = ?'', true]

and let the adapter deal with how to represent booleans for the column?

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org