开发者

Rails Runner throwing: undefined local variable or method `app' for main:Object (NameError)

I got a working Rails App (3.1.1). Now I wrote a runner (saved in app folder). When starting the runner with: rails r app/delete_old_addresses.rb

it dumps:

/Users/andreas/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/commands/runner.rb:49:in eval': undefined local variable or methodapp' for main:Object (NameError) from /Users/andreas/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/commands/runner.rb:49:in eval' from /Users/andreas/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/commands/runner.rb:49:in' from /Users/andreas/.rvm/gems开发者_Python百科/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/commands.rb:63:in require' from /Users/andreas/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/commands.rb:63:in' from script/rails:6:in require' from script/rails:6:in'

Any ideas why? My Webapp works perfectly fine.

The runner looks like this: class DeleteOldAddresses < ActiveRecord::Base end


I had the same issue. Running rails runner on my_script.rb (in my script folder, which I created on the same level as the app directory in Rails 4.0.0) directly gave me this error. When I ran rails runner script/my_script.rb it worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜