Yeah this will fix the problem - but I thought that constants should probably live with their model so that you can use the namespace ie
Order::DAYS_PER_WEEK Is there a best practice for constants? On Jun 5, 8:37 pm, Sandip Ransing <[email protected]> wrote: > If you have bunch of constants then add all contsants in one file say > constants.rb > and put contants.rb file in config/initializers > > what you say ?? > > - Sandip R~ > > On Fri, Jun 5, 2009 at 4:00 PM, Frederick Cheung <[email protected] > > > > > wrote: > > > On Jun 5, 11:19 am, Adrian <[email protected]> wrote: > > > Hi > > > > I've used a number of constants within my models to avoid magic > > > numbers: > > > > class Order < ActiveRecord::Base > > > > #snip > > > > DAYS_ALLOWED_FOR_CHANGE = 2 > > > DAYS_PER_WEEK = 7 > > > > #snip > > > > end > > > > However when running tests or starting the mongrel webserver I get > > > warning messages such as: > > > > .../order.rb:36: warning: already initialized constant > > > DAYS_ALLOWED_FOR_CHANGE > > > .../order.rb:37: warning: already initialized constant DAYS_PER_WEEK > > > > How can I track down where this is being reloaded? Should I worry > > > about it? > > > I suspect you are using require to manually load order when you don't > > need it. > > > The easiest thing to do would be to stick > > > puts caller > > > at the top of order.rb which will spew the callstack everytime > > order.rb is loaded. > > > Fred > > > > Any advice appreciated. > > > > Thanks > > > Adrian > > -- > Ruby on Rails > Developerhttp://sandip.sosblog.comhttp://funonrails.wordpress.comwww.joshsoftware.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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

