我有一个Rails应用程序中的rake任务。我想在rake任务中运行命令行命令。我该怎么做?我尝试了以下方法,但失败了:
desc "Sending the newsletter to all the users"
task :sending_mail do
run "cd #{RAILS_ROOT} && ar_sendmail -o -t NewsLetters -v"
system "cd #{RAILS_ROOT} && ar_sendmail -o -t NewsLetters -v &"
end
上述运行命令会抛出“run方法未定义”错误,而系统命令不会抛出任何错误,但也没有执行。