Ruby on Rails Friday, December 31, 2010

On Dec 31, 2010, at 3:15 AM, Jim wrote:

> My Article model has one boolean field called "draft". I'm using
> sqlite3 and rails 3.0.3. The boolean column (which was created
> with :boolean) is storing 'true' and 'false' as 't' and 'f' in the
> database, and the queries appear to be working fine for both cases.
> The problem is that when I look at the draft attribute on the query
> result objects, it is always "true":
>
> @articles = Article.where(:draft => false) # returns the correct
> rows
> logger.debug(@articles[0].draft) # will show 'true'

maybe try logger.debug( @articles[0].draft? ) since that's more
explicitly asking "is this true-ish?"

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment