RichardOnRails
2010-Apr-03 23:02 UTC
Specifying a decimal field precision/scale with scaffold requires 2 steps?
Hi, It appears to me that the command: ruby script/generate scaffold whatever money_field:decimal(10,2) will not generate a valid migration. Therefore it appears to me only two ways to achieve the desired result is: 1.1 Omit the the precision/scale on the scaffold command 1.2 Edit the migration file by following the "do |t| ... end" with the command: change_column :whatever :money_field, :amount, :decimal, :precision => 10, :scale => 2 I think this approach worked for me 2.1 Omit the money_field in it''s entirety 2.2 Create a second migration file an add the command: add_column :whatever :money_field, :amount, :decimal, :precision => 10, :scale => 2 I''m guessing this will work as well BTW, I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6.2, Firebug 1.5.3, MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15 What do you think? Best wishes, 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.
Conrad Taylor
2010-Apr-03 23:33 UTC
Re: Specifying a decimal field precision/scale with scaffold requires 2 steps?
On Sat, Apr 3, 2010 at 4:02 PM, RichardOnRails < RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> Hi, > > It appears to me that the command: > ruby script/generate scaffold whatever money_field:decimal(10,2) > will not generate a valid migration. > >Yes, the syntax is invalid and the correct syntax should be: ruby script/generate scaffold whatever money_field:decimal Next, you''ll simply have to edit the migration file to add the scale option. Good luck, -Conrad> Therefore it appears to me only two ways to achieve the desired result > is: > > 1.1 Omit the the precision/scale on the scaffold command > 1.2 Edit the migration file by following the "do |t| ... end" with > the command: > > change_column :whatever :money_field, :amount, :decimal, :precision > => 10, :scale => 2 > I think this approach worked for me > > 2.1 Omit the money_field in it''s entirety > 2.2 Create a second migration file an add the command: > > add_column :whatever :money_field, :amount, :decimal, :precision > => 10, :scale => 2 > I''m guessing this will work as well > > BTW, I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox > 3.6.2, Firebug 1.5.3, > MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15 > > What do you think? > > Best wishes, > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-Apr-04 01:13 UTC
Re: Specifying a decimal field precision/scale with scaffold requires 2 steps?
Thanks, Conrad. I thought since we''re on Rails 2 there''d be a better way. But I guess that scaffold is going to be deprecated soon, so core members don''t want to do any more work on it. Too bad, because it''s a way neat to get a concept-demo fast and amaze prospective clients. Best wishes, Richard On Apr 3, 7:33 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, Apr 3, 2010 at 4:02 PM, RichardOnRails < > > RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > Hi, > > > It appears to me that the command: > > ruby script/generate scaffold whatever money_field:decimal(10,2) > > will not generate a valid migration. > > Yes, the syntax is invalid and the correct syntax should be: > > ruby script/generate scaffold whatever money_field:decimal > > Next, you''ll simply have to edit the migration file to add the scale option. > > Good luck, > > -Conrad > > > Therefore it appears to me only two ways to achieve the desired result > > is: > > > 1.1 Omit the the precision/scale on the scaffold command > > 1.2 Edit the migration file by following the "do |t| ... end" with > > the command: > > > change_column :whatever :money_field, :amount, :decimal, :precision > > => 10, :scale => 2 > > I think this approach worked for me > > > 2.1 Omit the money_field in it''s entirety > > 2.2 Create a second migration file an add the command: > > > add_column :whatever :money_field, :amount, :decimal, :precision > > => 10, :scale => 2 > > I''m guessing this will work as well > > > BTW, I''m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox > > 3.6.2, Firebug 1.5.3, > > MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15 > > > What do you think? > > > Best wishes, > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.