我想在启动rake任务时从CLI发送2个参数。我试过这段代码:
namespace :tnx do
require_relative "transactions.rb"
include Cnp_transactions_modes
task :generate, [:clean_all] => [:environment] do |t, args|
if args[: clean_all] == 'true'
// something
end
if args[:times].empty?
Cnp_transactions_modes.create_transactions(args[:times])
end
end
end
但我得到错误:
rake aborted!
NoMethodError: undefined method `empty?' for nil:NilClass
我如何解决这个问题?