Forum: Ruby on Rails Fixture hash not available on the console in test env?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tyler A. (Guest)
on 2009-01-09 10:07
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.
Jay B. (Guest)
on 2009-02-24 18:29
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-...

Any ideas?
John B. (Guest)
on 2009-02-26 06:50
(Received via mailing list)
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.
Tyler A. (Guest)
on 2009-02-26 07:00
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.
This topic is locked and can not be replied to.