用于将命令行参数传递给rake任务的语法代码不正确

时间:2016-03-10 13:53:05

标签: ruby-on-rails

namespace :mails do
  desc "Send emails"
  task :send_emails => :environment do
    User.not_deleted.find_each do |user|
      Notifier.confirm_about_paid_access(user.id).deliver
    end
  end

  desc "Free subscription for users registered in 2011"
  task :free_subscription_for => :environment, :year do |t, args|
    year = args[:year]
    users = User::registered_in(year)
  end
end

显示错误: lib / tasks / mails.rake:10:语法错误,意外的keyword_do_block,expecting =>  任务:free_subscription_for => :环境,:年份do | t,args |

语法代码有什么不对?

1 个答案:

答案 0 :(得分:1)

试试这个,

async void btnSave_Click(object sender, EventArgs e)
{
    // get string result of the operation
    var result = await Task.Run(() => SaveTheData());
    if (result != "OK")
    {
        msgBox = new CustomMessageBox(
                    "Файл добавлен в базу, строки " + result +
                    " не были добавлены по причине неверных входных данных",
                    "Уведомление");
        msgBox.Show();
    }
}

请注意namespace :mails do desc "Send emails" task :send_emails => :environment do User.not_deleted.find_each do |user| Notifier.confirm_about_paid_access(user.id).deliver end end desc "Free subscription for users registered in 2011" task :free_subscription_for, [:year] => :environment do |t, args| year = args[:year] users = User::registered_in(year) end end 任务的语法。

执行任务时,语法为:free_subscription_for

希望这有帮助!