views:

21

answers:

1

I am trying to access the constant VALID_FIND_OPTIONS defined in ActiveRecord::Base (active_record/base.rb Line 2402 Rails 2.3.5).

ActiveRecord::Base::VALID_FIND_OPTIONS

I get the NameError exception.

NameError: uninitialized constant ActiveRecord::Base::VALID_FIND_OPTIONS

I have accessed the class constants in other libraries using the similar syntax before. I am not sure where I am going wrong.

A: 

Where is the code that tries to get ActiveRecord::Base::VALID_FIND_OPTIONS?

If you are defining a class before ActiveRecord is loaded, then the constant will not be available.

You can force ActiveRecord to be loaded by requiring it. In some cases, you will have to require rubygems before requiring active_record.

Try requiring them both:

require 'rubygems'
require 'active_record'

# you should now be able to access ActiveRecord::Base::VALID_FIND_OPTIONS
egarcia
I access the constant in my controller. I get the same error when I use it from rails console (where active_record is loaded by default).
KandadaBoggu