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 __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com
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 --- CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > > __________________________________ > Yahoo! FareChase: Search multiple travel sites in one click. > http://farechase.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Mail - PC Magazine Editors'' Choice 2005 http://mail.yahoo.com
This appears to be a problem with the latest ruby-postgres snapshot. I''ve filed a ticket. csn --- CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > 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 > > > --- CSN <cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > 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 > > > > > > > > __________________________________ > > Yahoo! FareChase: Search multiple travel sites in one click. > > http://farechase.yahoo.com > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors'' Choice 2005 > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs