RichardOnRails
2010-Mar-10 20:41 UTC
Decimal fields generated in Rails 2.3.5 act like strings, sort of
Hi All, I just created a new CRUD "expense" (using Rails 2.3.5 scaffold) which included "amount:decimal". When I: 1. populated the amount field of a new expense with 5 characters: 12.50 and 2. saved the new record I got a display of the new record that showed Amount to be merely "12". I clicked Update and put my cursor over the data field for Amount and got a tool-tip display of 12.50. On the other hand, Date seems to be handled fine IMHO, both on input and display. Is the problem that MySQL 2.0.37 doesn''t really implement "decimal" and so I should switch to float and then do my own formatting for a text field? Thanks in Advance, Richard -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2010-Mar-10 21:05 UTC
Re: Decimal fields generated in Rails 2.3.5 act like strings
RichardOnRails wrote:> I just created a new CRUD "expense" (using Rails 2.3.5 scaffold) which > included "amount:decimal". When I: > > 1. populated the amount field of a new expense with 5 characters: > 12.50 and > 2. saved the new record > > I got a display of the new record that showed Amount to be merely > "12". > > I clicked Update and put my cursor over the data field for Amount and > got a tool-tip display of 12.50. > > On the other hand, Date seems to be handled fine IMHO, both on input > and display. > > Is the problem that MySQL 2.0.37 doesn''t really implement "decimal" > and so I should switch to float and then do my own formatting for a > text field?MySQL 2.0.37? Wow! I''m shocked that''s even useable with Rails, or anything else modern. That being said I assume you added the :precision and :scale for the field to your migration? If so then yes, you might have issues with that old of a version of MySQL. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
RichardOnRails
2010-Mar-12 00:27 UTC
Re: Decimal fields generated in Rails 2.3.5 act like strings
Hi Robert, Thanks for your help. I mistakenly reported MySQL''s version as 2.0.37. It''s actually 5.0.37. But that''s a little behind the times, so I upgraded to 5.1.44 which seems to work fine in general. But I ran into a snag getting my RoR working with 5.1.44. I think the problem is I only dumped/imported the development database. I''d like to find a good way to be able to switch back and forth between MySQL versions on a WinXP/SP3 platform. I''m going to post a second question on this if Google doesn''t turn up any thing good for me. Best wishes, Richard On Mar 10, 4:05 pm, Robert Walker <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> RichardOnRails wrote: > > I just created a new CRUD "expense" (using Rails 2.3.5 scaffold) which > > included "amount:decimal". When I: > > > 1. populated the amount field of a new expense with 5 characters: > > 12.50 and > > 2. saved the new record > > > I got a display of the new record that showed Amount to be merely > > "12". > > > I clicked Update and put my cursor over the data field for Amount and > > got a tool-tip display of 12.50. > > > On the other hand, Date seems to be handled fine IMHO, both on input > > and display. > > > Is the problem that MySQL 2.0.37 doesn''t really implement "decimal" > > and so I should switch to float and then do my own formatting for a > > text field? > > MySQL 2.0.37? Wow! I''m shocked that''s even useable with Rails, or > anything else modern. > > That being said I assume you added the :precision and :scale for the > field to your migration? If so then yes, you might have issues with that > old of a version of MySQL. > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.