我试图从我的应用程序的rake任务中的gem(geocoder https://github.com/alexreisner/geocoder)添加一个rake任务,因为我希望在构建数据库之后运行该任务。从应用程序rake任务运行gems rake任务
所以我有一个Rake文件
task :geolocal do
spec = Gem::Specification.find_by_name 'geocoder'
load "#{spec.gem_dir}/lib/tasks/geocoder.rake"
puts '##################GEOCODING##############'
Rake::Task["geocode:all CLASS=ProposedAccomodation"].execute
end
这里面的代码只是开始关注此问题Ruby Rake load tasks from a gem 但我不断收到同样的错误
Don't know how to build task 'geocode:all CLASS=ProposedAccomodation'
任何线索我做错了吗?
[Rake Execute With Multiple Arguments]可能重复(http://stackoverflow.com/questions/8033303/rake-execute-with-multiple-arguments) – phoet 2014-10-10 12:43:24
您必须将该类作为参数传递才能执行。 – phoet 2014-10-10 12:43:48
@phoet我试图从一个小时来指定参数,以不同的方式,在你链接的问题中看到,以及这些http://stackoverflow.com/questions/825748/how-do-i-pass -command-line-arguments-to-rake-task,但我不断收到'请指定CLASS(模型)'错误。 (Rake :: TaskArguments.new(stuff_args.keys,stuff_args),这是我最后一次尝试的:'Rake :: Task [“geocode:all”]。(Rake :: TaskArguments.new(stuff_args.keys,stuff_args .values))'任何线索? – sissy 2014-10-10 14:36:42