# Error loading fixtures for classes that set\_table\_name

**URL:** <https://www.ruby-forum.com/t/error-loading-fixtures-for-classes-that-set-table-name/196722>\
**Category:** Rails\
**Created:** [June 23, 2008, 6:11pm UTC](https://www.ruby-forum.com/t/error-loading-fixtures-for-classes-that-set-table-name/196722 "2008-06-23T18:11:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/977dab/32.png) [@bcm](https://www.ruby-forum.com/u/bcm)\
**Post date:** [June 23, 2008, 6:11pm UTC](https://www.ruby-forum.com/t/error-loading-fixtures-for-classes-that-set-table-name/196722/1 "2008-06-23T18:11:45Z")

</div>

Hi all,

I just hit a big wall involving a legacy database. I’ve got an active  
record class called “School” that uses “set\_table\_name ‘old\_school’” to  
map to a legacy database table:

class School \< ActiveRecord::Base  
set\_table\_name ‘old\_school’  
end

It works great, until I’m testing and I want to use fixtures. I’ve got  
a fixtures file called “old\_school.yml” that doesn’t load. Following  
some googled advice  
([http://www.missiondata.com/blog/uncategorized/80/rails-fixtures-with-models-using-set\_table\_name/](http://www.missiondata.com/blog/uncategorized/80/rails-fixtures-with-models-using-set_table_name/))  
I learned that I had to use set\_fixture\_class to be able to map the  
fixture back to the class name:

# in test\_helper.rb

class Test::Unit::TestCase  
self.use\_transactional\_fixtures = true  
self.use\_instantiated\_fixtures = false

set\_fixture\_class :old\_school =\> School

fixtures :all  
end

Seems like it ought to work, but the fixtures still don’t load!

Looking in my test.log I find:

Unable to load old\_school, underlying cause no such file to load –  
old\_school

/Library/Ruby/Site/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active\_support/dependencies.rb:509:in  
`require' /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new\_constants\_in’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active\_support/dependencies.rb:509:in  
`require' /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:101:in `require\_or\_load’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active\_support/dependencies.rb:60:in  
`depend_on' /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:456:in `require\_dependency’  
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active\_record/fixtures.rb:855:in  
`try_to_load_dependency' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/fixtures.rb:870:in `require\_fixture\_classes’  
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active\_record/fixtures.rb:867:in  
`each' /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/fixtures.rb:867:in `require\_fixture\_classes’  
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active\_record/fixtures.rb:850:in  
`fixtures' ./test/test_helper.rb:15 test/functional/admin_controller_test.rb:1:in `require’  
test/functional/admin\_controller\_test.rb:1

If I “require ‘school’” by hand, it makes no difference. The fixtures  
still don’t load.

Has anybody run in to this? Does anyone have any suggestions?

Thanks!

Brent
