我刚刚将一个 Sinatra 应用程序部署到 heroku,该应用程序包含两个 rake 任务:
task :create_db , [:db_id , :db_name]
task :destroy_db , [:db_id, :token]
当我跑
heroku run rake -T
在控制台中,Heroku 打印以下响应:
(in /app)
rake create_db[db_id,db_name] # Creation count database task
rake destroy_db[db_id,token] # Destroy database task
但是,当我运行时:
heroku run rake create_db['test', 'test database']
它响应以下错误:
(in /app)
rake aborted!
Don't know how to build task 'create_db[test,'
/usr/local/lib/ruby/1.9.1/rake.rb:1720:in `[]'
/usr/local/lib/ruby/1.9.1/rake.rb:2040:in `invoke_task'
/usr/local/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
/usr/local/lib/ruby/1.9.1/rake.rb:2019:in `each'
/usr/local/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
/usr/local/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/local/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/usr/local/lib/ruby/1.9.1/rake.rb:1992:in `run'
/usr/local/bin/rake:31:in `<main>'
我不太确定为什么会失败,但我的猜测是它与字符串参数有关。正如你在上面看到的,它说“不知道如何构建任务'create_db [test',测试显示没有字符串。
知道如何让这个任务从命令行运行吗?