From: Rob Biedenharn Date: 2007-07-06T04:51:16+09:00 Subject: Re: CONST initialization... On Jul 5, 2007, at 3:12 PM, Jean Nibee wrote: > How come this works when I access Orders::PAYMENT_TYPES > > Error thrown: > /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ > dependencies.rb:477:in > `const_missing' > > I have moved the PAYMENT_TYPES map around and it even is okay if it's > after the has_many :item_lines accessor, but not if it's after the > 'validation' accessors. > > Thanks. I think you've answered your own question, but you might not understand why. The ruby interpreter is "executing" each line within the class definition as it is encountered. If there's no PAYMENT_TYPES when the validates_inclusion_of line is reached, it really doesn't matter that it *does* appear later in the class definition. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com