Uninitialized constant (NameError)


#1

Anyone knows why Test #1 works, but not Test #2

Test #1

require ‘contact/company’
require ‘contact/company_office’

def main
@companies = Contact::Company.find(:all,
:include=>[‘company_office’],
:limit=>20)
end
main

Test #2

require ‘contact/company’
require ‘contact/company_office’

def main
puts Contact::Company.name # the only difference from test 1
@companies = Contact::Company.find(:all,
:include=>[‘company_office’],
:limit=>20)
end
main

In (2), I am getting the following

/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:892:in
guard_against_missing_reflections': Association was not found; perhaps you misspelled it? You specified :include => :company_office (ActiveRecord::ConfigurationError) from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:890:inguard_against_missing_reflections’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:846:in
find_with_associations' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:infind’
from ./search.rb:12:in main' from ./search.rb:21 from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:inrequire_or_load’
… 22 levels…
from …/…/…/config/…/app/models/contact/company.rb:5
from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in require' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:inrequire’