# Fixtures and table name

**URL:** <https://www.ruby-forum.com/t/fixtures-and-table-name/50312>\
**Category:** Rails\
**Created:** [December 15, 2005, 1:54am UTC](https://www.ruby-forum.com/t/fixtures-and-table-name/50312 "2005-12-15T01:54:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Fuller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cc9497/32.png) [@Michael\_Fuller](https://www.ruby-forum.com/u/Michael_Fuller)\
**Post date:** [December 15, 2005, 1:54am UTC](https://www.ruby-forum.com/t/fixtures-and-table-name/50312/1 "2005-12-15T01:54:34Z")

</div>

Is there a way to use table name other than the default or to turn it  
around have multiple fixture files associated to the same table.

Here’s my use case: I have multiple unit test classes that all work with  
the same model class and hence the same database table. However, for  
each test class I want the data to be in a different state.

So I’d like to have something like

class ModelATest \< Test::Unit::TestCase  
fixtures :models\_a # use file models\_a.yml for table models

…  
end

class ModelBTest \< Test::Unit::TestCase  
fixtures :models\_b # use file models\_b.yml for table models

…  
end

Thanks.

Mike

---

<div class="post-metadata">

**Author:** ![Michael\_Fuller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cc9497/32.png) [@Michael\_Fuller](https://www.ruby-forum.com/u/Michael_Fuller)\
**Post date:** [December 16, 2005, 4:15pm UTC](https://www.ruby-forum.com/t/fixtures-and-table-name/50312/2 "2005-12-16T16:15:03Z")

</div>

You probably want something like this:  
[http://dev.rubyonrails.org/ticket/1911](http://dev.rubyonrails.org/ticket/1911)

It’s scheduled for Rails 1.1, we’ve integrated it into the engines  
plugin in the meantime.

- james

---

<div class="post-metadata">

**Author:** ![Michael\_Fuller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cc9497/32.png) [@Michael\_Fuller](https://www.ruby-forum.com/u/Michael_Fuller)\
**Post date:** [July 27, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/fixtures-and-table-name/50312/3 "2006-07-27T23:18:03Z")

</div>

Hey James,

I’m desperately trying to use your implemntation of flexible fixtures.  
Here’s my line :  
fixture :scr\_commit, :table\_name=\>“salesconfigreporting\_history”,  
:file\_name=\>“scr\_history\_committed”

But the fiixture data is not loaded when the test is run.  
I’ve tried the data on a standard #fixtures call with the standard  
filename  
and it works OK.

Ideas?
