As recomended by AWDWR (pg 85), is everyone using integer to store decimal values? Or is there a better way to do this? Thanks in advance Thushan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi ! 2006/11/17, Thushan <thushan.abeysekera@gmail.com>:> > As recomended by AWDWR (pg 85), is everyone using integer to store > decimal values? > Or is there a better way to do this?I use integer columns with a composed_of :class_name => 'Money' Hope that helps ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 17, 2006, at 4:34 AM, Thushan wrote:> As recomended by AWDWR (pg 85), is everyone using integer to store > decimal values? > Or is there a better way to do this?The new edition recommends using decimal columns once Rails 1.2 comes out. Cheers Dave
Out of curiosity what does rails 1.2 have to do with the use of decimal columns? I''ve been using decimal columns for my currency needs on my site for over a year without any issues (that I know of). I''ve done testing to ensure my math is correct and haven''t seen any problems. I''m afraid of what problems I''m missing by not understanding the issue at large. I''m using rails 1.1.6. -Michael http://javathehutt.blogspot.com On Nov 17, 2006, at 7:13 AM, Dave Thomas wrote:> > On Nov 17, 2006, at 4:34 AM, Thushan wrote: > >> As recomended by AWDWR (pg 85), is everyone using integer to store >> decimal values? >> Or is there a better way to do this? > > > The new edition recommends using decimal columns once Rails 1.2 > comes out. > > > Cheers > > > Dave--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Kovacs wrote:> Out of curiosity what does rails 1.2 have to do with the use of > decimal columns?Check out: http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Random/Rounding.rdoc I believe that versions of Rails before 1.2, convert database decimal amounts to floats in Ruby. If you check out the link above, you can see that unfortunately that doesn''t provide the precision that''s desired for cash-related applications. A patch was submitted: http://dev.rubyonrails.org/ticket/5454 that fixes this and provides support for high-precision decimal columns to BigDecimal Ruby objects. The patch will be a part of the core in Rails 1.2. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---