# Fixture hash not available on the console in test env?

**URL:** <https://www.ruby-forum.com/t/fixture-hash-not-available-on-the-console-in-test-env/157302>\
**Category:** Rails\
**Created:** [January 9, 2009, 9:07am UTC](https://www.ruby-forum.com/t/fixture-hash-not-available-on-the-console-in-test-env/157302 "2009-01-09T09:07:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![redii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/73ab20/32.png) [@redii](https://www.ruby-forum.com/u/redii)\
**Post date:** [January 9, 2009, 9:07am UTC](https://www.ruby-forum.com/t/fixture-hash-not-available-on-the-console-in-test-env/157302/1 "2009-01-09T09:07:10Z")

</div>

While the generated id certainly works well for tests, it was previously  
easier when loading the test console and interacting with your model  
relationships. Is there an expectation to make the fixture hashes  
available on the test console? Currently running 2.2.2.

---

<div class="post-metadata">

**Author:** ![redii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/73ab20/32.png) [@redii](https://www.ruby-forum.com/u/redii)\
**Post date:** [February 24, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/fixture-hash-not-available-on-the-console-in-test-env/157302/2 "2009-02-24T17:29:34Z")

</div>

Tyler Arrigoni wrote:

> While the generated id certainly works well for tests, it was previously  
> easier when loading the test console and interacting with your model  
> relationships. Is there an expectation to make the fixture hashes  
> available on the test console? Currently running 2.2.2.

I found the following irb script, but have not been able to get it to  
work. The code all seems proper, and I have been able to get my irb.rc  
file to load properly, but it doesn’t seem to be overloading  
find\_from\_ids properly.

[http://railsbros.de/2008/2/26/script-console-hack-to-load-fixtures](http://railsbros.de/2008/2/26/script-console-hack-to-load-fixtures)

Any ideas?

---

<div class="post-metadata">

**Author:** ![redii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/73ab20/32.png) [@redii](https://www.ruby-forum.com/u/redii)\
**Post date:** [February 26, 2009, 5:50am UTC](https://www.ruby-forum.com/t/fixture-hash-not-available-on-the-console-in-test-env/157302/3 "2009-02-26T05:50:16Z")

</div>

Hi,

On Feb 24, 2009, at 8:29 AM, Jay Bo wrote:

> Tyler Arrigoni wrote:
> 
> > While the generated id certainly works well for tests, it was  
> > previously  
> > easier when loading the test console and interacting with your model  
> > relationships. Is there an expectation to make the fixture hashes  
> > available on the test console? Currently running 2.2.2.

You can write this pretty easily yourself using Fixtures.identify:

$ script/console

> > require “active\_record/fixtures”  
> > def fixture klass, name; klass.find Fixtures.identify(name) end  
> > fixture User, “bob”

~ j.

---

<div class="post-metadata">

**Author:** ![redii](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/73ab20/32.png) [@redii](https://www.ruby-forum.com/u/redii)\
**Post date:** [February 26, 2009, 6:00am UTC](https://www.ruby-forum.com/t/fixture-hash-not-available-on-the-console-in-test-env/157302/4 "2009-02-26T06:00:17Z")

</div>

John B. wrote:

> You can write this pretty easily yourself using Fixtures.identify:
> 
> $ script/console
> 
> > > require “active\_record/fixtures”  
> > > def fixture klass, name; klass.find Fixtures.identify(name) end  
> > > fixture User, “bob”
> 
> ~ j.

Indeed. Nice.
