Ar_fixtures "broken?" in rails 1.2.1?

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:ineval’
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:inrequire’
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

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.

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:ineval’
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:inrequire’
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

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