Postgres real being treated as boolean?


#1

I have a real number column (“real”) in Postgres and I think it might be
being treated as a
boolean. In my template I have:

<%= number_with_precision(item.vote_average, 2) %>

and it’s outputting 1.00 for everything (they’re not all 1’s in the
database). Actually, I have to
enclose that code in begin…rescue otherwise I get an “undefined method
‘to_f’” if
item.vote_average is 0 in the database.

what’s happening?
csn


#2

Something wacky is going on. When I do ‘debug(item)’ I get values like:

vote_average: 1
vote_average: true
vote_average:

While in the database, vote_average’s (type “real”) values are like
3.5423, 4, 2.451, etc.

Anybody know what the problem is?

thanks
csn


#3

This appears to be a problem with the latest ruby-postgres snapshot.
I’ve filed a ticket.

csn