Hi, In the following migration I am trying to create a decimal column called stars. After rake migrate you can see that the field does not come out right in mysql. The decimal column has no decimal part. Does anyone know what I am doing wrong or should be doing? create_table :areas do |t| t.column :name, :string t.column :stars, :decimal, :precision=>4, :scale=>3 end produces +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | id | int(11) | | PRI | NULL | auto_increment | | name | varchar(255) | YES | | NULL | | | stars | decimal(10,0) | YES | | NULL | | +-------------+---------------+------+-----+---------+----------------+ I think that I''m hoping to see decimal(4,3) Thanks, Peter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Aug 28, 2006, at 20:53, Peter Michaux wrote:> n the following migration I am trying to create a decimal column > called stars. After rake migrate you can see that the field does not > come out right in mysql. The decimal column has no decimal part. Does > anyone know what I am doing wrong or should be doing?I''d guess you''re not on edge Rails. 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 -~----------~----~----~----~------~----~------~--~---
From http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#M000569 it looks like migrations allow a :float type, and don''t allow you to set precision or scale options. I''d try changing :decimal to :float and leaving in :precision and :scale to see what happens On Monday 28 August 2006 15:53, Peter Michaux wrote:> Hi, > > In the following migration I am trying to create a decimal column > called stars. After rake migrate you can see that the field does not > come out right in mysql. The decimal column has no decimal part. Does > anyone know what I am doing wrong or should be doing? > > > create_table :areas do |t| > t.column :name, :string > t.column :stars, :decimal, :precision=>4, :scale=>3 > end > > > produces > > > +-------------+---------------+------+-----+---------+----------------+ > > | Field | Type | Null | Key | Default | Extra | > > +-------------+---------------+------+-----+---------+----------------+ > > | id | int(11) | | PRI | NULL | auto_increment | > | name | varchar(255) | YES | | NULL | | > | stars | decimal(10,0) | YES | | NULL | | > > +-------------+---------------+------+-----+---------+----------------+ > > > I think that I''m hoping to see decimal(4,3) > > Thanks, > Peter > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---