Rake =&gt;对于#<array:0x10153ca08> </array:0x10153ca08> undefined方法`to_sentence'>

时间:2011-07-20 09:37:21

标签: ruby-on-rails ruby rake rakefile

我无法在我的项目中执行rake任务。我总是收到以下错误消息:

rake aborted!
undefined method `to_sentence' for #<Array:0x10153c800>
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rails-2.3.11/lib/tasks/rails.rb:10
/Users/username/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/Users/username/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Users/username/Documents/project/Rakefile:10
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/username/.rvm/gems/ruby-1.8.7-p334/gems/rake-0.8.7/bin/rake:31
/Users/username/.rvm/gems/ruby-1.8.7-p334/bin/rake:19:in `load'
/Users/username/.rvm/gems/ruby-1.8.7-p334/bin/rake:19

ruby​​ 1.8.7(2011-02-18 patchlevel 334)[i686-darwin10.8.0]

Rails 2.3.11

rake,版本0.8.7

我尝试使用rake 0.9.2和/或ruby 1.9.2但没有取得更多成功。

以下是我的Rakefile的内容:

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rdoc/task'

require 'tasks/rails'

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

如果这是一个自定义Rake任务......在Rails中定义了to_sentence数组扩展,那么您需要确保加载Rails。

确保您在rake任务中加载环境:

task :my_task => :environment do
...

如果这不是自定义Rake任务,那么您的环境似乎有问题。尝试升级RVM。

答案 1 :(得分:0)

如果您安装了bundler,请尝试

bundle exec rake --tasks

不确定它是否有用但值得一试。