具有多个参数和模型访问的Rake任务不起作用

时间:2022-02-27 00:17:19

I am getting the following error running my rake task

我在运行rake任务时会得到以下错误

rake store_reports["1", "2"]
rake aborted!
Don't know how to build task 'store_reports[1,'

My rake task takes 2 parameters and needs to access models inside it. Here is the task

我的rake任务有两个参数,需要访问其中的模型。这是任务

task :store_reports, [:start_date, :end_date] => :environment do |t, args|
    puts args.start_date
end

I referenced both of there * questions, but the first answer did not work, and in the second one the author seems to have solved it but he never posted his answer.

我提到了这两个*的问题,但是第一个答案无效,在第二个问题中,作者似乎已经解决了这个问题,但是他从来没有发布他的答案。

rake aborted! undefined method `map' for :name:Symbol rake task with multiple parameters - I got stuck

rake流产!未定义的方法“map”用于:name:符号rake任务,带有多个参数——我被卡住了

Heres some extra info. Where I run rake -T I dont see my rake task there

这是一些额外的信息。我在哪里运行rake -T,我在那里没有看到rake任务

1 个解决方案

#1


23  

try

试一试

rake store_reports["1","2"]

as per How to pass command line arguments to a rake task.

根据如何将命令行参数传递给rake任务。

the parser is not liking the space between your parameters

解析器不喜欢参数之间的空间

#1


23  

try

试一试

rake store_reports["1","2"]

as per How to pass command line arguments to a rake task.

根据如何将命令行参数传递给rake任务。

the parser is not liking the space between your parameters

解析器不喜欢参数之间的空间