Having duly considered it, I withdraw my suggestion of a 'tradeoff'. I'm better off for your comments, so thanks all.
Grar On Apr 5, 3:38 pm, Colin Law <clan...@googlemail.com> wrote: > On 5 April 2010 19:48, Grary <grary.sti...@gmail.com> wrote: > > > Colin, > > > So, there is something I will regret either in terms of i) db > > performance or ii) db maintenance by not using default float (int) > > defaults where appropriate? > > > My view of the tradeoff was: 1) coding defaults to the attributes in a > > migration vs. 2) calling to_f (to_i)on them in logic. > > Sorry I don't understand what you are saying here about there being a > tradeoff. > > Colin > > > > > With no previous experience in the matter, I'll adopt your proposal. > > > Thanks, > > >Grar > > > On Apr 5, 1:35 pm, Colin Law <clan...@googlemail.com> wrote: > >> On 5 April 2010 17:57, Grary <grary.sti...@gmail.com> wrote: > > >> > What is the best practice for handling ActiveRecord attributes in > >> > logic when those attributes were allowed to be nil? I've been handling > >> > the possibly-nil status of my Numeric attributes in my logic by > >> > calling to_f (to_i) on them, but I wonder if there's a better > >> > practice? For example, default values could be set in the migration or > >> > validations could set blank fields to a default. > > >> > Any suggestions on the best practice in this case? > > >> If you are treating nil as effectively 0.0 rather than no value then I > >> think there is a good argument for setting a default value, and not > >> allowing null in the db. > > >> If you need to distinguish nil as being 'no value' which is different > >> from 0.0 then you cannot use a default value. > > >> Colin > > > -- > > 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-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.