Maybe it''s all in my head, but I''m having the strangest little issue ever. My pricetags in my rails app are always whole numbers. Rails seems to completely ignore my decimal input. So as a consequence, 10.41 becomes 10.00, always. Here''s some worthwhile stuff: within my 004_create_products.rb file: :price, :decimal, :percision => 2, :default => 0 And calling the product price in a view: <%= number_to_currency(product.price, {:precision => 2}) %> That''s all I can really think of that could be of help. Is this all in my head, or am I retarded and missing something? -- 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 -~----------~----~----~----~------~----~------~--~---
I''m hoping that you just made a simple copy/paste error on that> :price, :decimal, :percision => 2, :default => 0^^^ percision? -- James Mitchell On Nov 27, 2007, at 4:15 PM, Cade D. wrote:> > Maybe it''s all in my head, but I''m having the strangest little issue > ever. My pricetags in my rails app are always whole numbers. Rails > seems > to completely ignore my decimal input. So as a consequence, 10.41 > becomes 10.00, always. > > Here''s some worthwhile stuff: > > > within my 004_create_products.rb file: > > :price, :decimal, :percision => 2, :default => 0 > > And calling the product price in a view: > > <%= number_to_currency(product.price, {:precision => 2}) %> > > That''s all I can really think of that could be of help. Is this all in > my head, or am I retarded and missing something? > -- > 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 -~----------~----~----~----~------~----~------~--~---
As stated in previous reply, make sure your migration is right. You can also verify the precision in the db tables. -- James Mitchell On Nov 27, 2007, at 4:15 PM, Cade D. wrote:> > Maybe it''s all in my head, but I''m having the strangest little issue > ever. My pricetags in my rails app are always whole numbers. Rails > seems > to completely ignore my decimal input. So as a consequence, 10.41 > becomes 10.00, always. > > Here''s some worthwhile stuff: > > > within my 004_create_products.rb file: > > :price, :decimal, :percision => 2, :default => 0 > > And calling the product price in a view: > > <%= number_to_currency(product.price, {:precision => 2}) %> > > That''s all I can really think of that could be of help. Is this all in > my head, or am I retarded and missing something? > -- > 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 -~----------~----~----~----~------~----~------~--~---
On 11/27/07, Cade D. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Maybe it''s all in my head, but I''m having the strangest little issue > ever. My pricetags in my rails app are always whole numbers. Rails seems > to completely ignore my decimal input. So as a consequence, 10.41 > becomes 10.00, always. > > Here''s some worthwhile stuff: > > > within my 004_create_products.rb file: > > :price, :decimal, :percision => 2, :default => 0 >You''re asking for a column with two significant digits and don''t mention that you want decimal places. Isak --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---