# Ar\_fixtures "broken?" in rails 1.2.1?

**URL:** <https://www.ruby-forum.com/t/ar-fixtures-broken-in-rails-1-2-1/83924>\
**Category:** Rails\
**Created:** [January 30, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/ar-fixtures-broken-in-rails-1-2-1/83924 "2007-01-30T20:52:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 30, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/ar-fixtures-broken-in-rails-1-2-1/83924/1 "2007-01-30T20:52:02Z")

</div>

I am trying to use the plugin ar\_fixtures that I have just installed  
using

# script/plugins install ar\_fixtures

I have a model called login

$ ll app/models/l\*  
-rw-rw-r-- 1 byrnejb byrnejb 125 2007-01-17 16:39 app/models/login.rb

that I added to the development database via a migration and which has  
been updated to contain data via a rails application. However, when I  
try this:

$ script/runner “login.to\_fixture”

I get this:

–\>  
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/runner.rb:47:  
undefined local variable or method `login' for main:Object (NameError) from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in`eval’  
from  
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/runner.rb:47  
from /usr/lib/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from script/runner:3  
\<–

The rake version “rake db:fixture:dump MODEL=login” gives essentially  
the same result.

Rails 1.2.1  
ruby 1.8.5 (2006-08-25) [i386-linux]

Any help to get this working would be most appreciated.

Jim

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 30, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/ar-fixtures-broken-in-rails-1-2-1/83924/2 "2007-01-30T21:18:51Z")

</div>

I think you need to use the class name to do to\_fixture. (capitalized,  
cos  
it’s a constant).

ruby script/runner “Login.to\_fixture”

If that’s not your problem, let me know.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 30, 2007, 9:44pm UTC](https://www.ruby-forum.com/t/ar-fixtures-broken-in-rails-1-2-1/83924/3 "2007-01-30T21:44:07Z")

</div>

Brian H. wrote:

> I think you need to use the class name to do to\_fixture. (capitalized,  
> cos  
> it’s a constant).
> 
> ruby script/runner “Login.to\_fixture”
> 
> If that’s not your problem, let me know.

This is what is in app/models/login.rb

$ cat app/models/login.rb  
class Login  
attr\_accessor :errors  
attr\_accessor :name, :password

def initialize  
@errors = Array.new  
end

end

and this is what happens when I try script runner.

$ script/runner “Login.to\_fixture”  
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/runner.rb:47:  
undefined method `to_fixture' for Login:Class (NoMethodError) from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in`eval’  
from  
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/runner.rb:47  
from /usr/lib/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
from script/runner:3

and this is the relevant portion from runner.rb

39 require RAILS\_ROOT + ‘/config/environment’  
40  
41 if code\_or\_file.nil?  
42 $stderr.puts “Run ‘#{$0} -h’ for help.”  
43 exit 1  
44 elsif File.exists?(code\_or\_file)  
45 eval(File.read(code\_or\_file))  
46 else  
47 eval(code\_or\_file)  
48 end

and from custom\_require.rb

26 def require(path) # :nodoc:  
27 gem\_original\_require path  
28 rescue LoadError =\> load\_error  
29 begin  
30 if spec = Gem.searcher.find(path)  
31 Gem.activate(spec.name, false, “= #{spec.version}”)  
32 gem\_original\_require path  
33 else  
34 raise load\_error  
35 end  
36 end  
37 end

Thanks for your help.

Jim

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 30, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/ar-fixtures-broken-in-rails-1-2-1/83924/4 "2007-01-30T21:54:46Z")

</div>

James B. wrote:

> Brian H. wrote:
> 
> > I think you need to use the class name to do to\_fixture. (capitalized,  
> > cos  
> > it’s a constant).
> > 
> > ruby script/runner “Login.to\_fixture”
> > 
> > If that’s not your problem, let me know.

Never Mind. Your first answer was correct. I am working with a Goldberg  
generated site and had the misfortune to pick a meaningless model after  
failing to use the correct syntax on other valid ones. As tyou point  
out, the correct usage for rake db:fixture:dump MODEL=x and  
script/runner “x.to\_fixture” is for MODEL=ModelClassName as defined as  
inheriting from ActiveRecord::Base. Thanks!

Jim
