Apologies for being the densest person in the rails domain...
I''m using a freshly generated model (Addressbook).  The table
(Addressbooks) exists in my development, and test databases.
"rake" gives me the following error (and likewise with most of my
models):
Can someone walk me through what I''m doing wrong?  Something that
confuses me is the "setup_without_fixtures" call in the stack trace...
I thought I WAS using fixtures...?
=============Error:
  1) Error:
test_truth(AddressbookTest):
NameError: uninitialized constant Addressbook
   
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:183:in
`const_missing''
    ./test/unit/addressbook_test.rb:9:in `setup_without_fixtures''
   
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/fixtures.rb:458:in
`setup''
   
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/fixtures.rb:456:in
`setup''
=====================Test:
require File.dirname(__FILE__) + ''/../test_helper''
class AddressbookTest < Test::Unit::TestCase
  fixtures :addressbooks
  def setup
    @addressbook = Addressbook.find(1)
  end
  # Replace this with your real tests.
  def test_truth
    assert_kind_of Addressbook,  @addressbook
  end
end
======================Fixture: (addressbooks.yml)
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first_addressbook:
  id: 1
  customer_id: 1
  name: name1
  nickname: nickname1
  country: USA
  
=================Model: (addressbook.rb)
class Addressbook < ActiveRecord::Base
  :belongs_to :customer
end
On 5/15/05, Michael Campbell <michael.campbell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Apologies for being the densest person in the rails domain... > > I''m using a freshly generated model (Addressbook). The table > (Addressbooks) exists in my development, and test databases. > > "rake" gives me the following error (and likewise with most of my models): > > Can someone walk me through what I''m doing wrong? Something that > confuses me is the "setup_without_fixtures" call in the stack trace... > I thought I WAS using fixtures...? > > =============> Error: > > 1) Error: > test_truth(AddressbookTest): > NameError: uninitialized constant Addressbook > c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:183:in > `const_missing'' > ./test/unit/addressbook_test.rb:9:in `setup_without_fixtures'' > c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/fixtures.rb:458:in > `setup'' > c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/fixtures.rb:456:in > `setup''Some more information. I made a fresh project and ran tests after every step. It starts failing with the above error on this model (and EVERY model I have) when I add any sort of AR assocation; has_and_belongs_to_many, has_many, belongs_to, etc. That is, in the above case, if I leave off my "belongs_to :customer", it works. Put it in and it fails. What magic are those directives causing to cause ruby not to "see" my models?
> Some more information. I made a fresh project and ran tests after > every step. It starts failing with the above error on this model (and > EVERY model I have) when I add any sort of AR assocation; > has_and_belongs_to_many, has_many, belongs_to, etc. That is, in the > above case, if I leave off my "belongs_to :customer", it works. Put > it in and it fails. > > What magic are those directives causing to cause ruby not to "see" my models?Argh, solved. I was using ":belongs_to", (etc.) and not simply "belongs_to" (no colon).