rake 任务参数传递问题解决

原文 :  https://robots.thoughtbot.com/how-to-use-arguments-in-a-rake-task

 

namespace :tweets do
  desc 'Send some tweets to a user'
  task :send, [:username] => [:environment] do |t, args|
    Tweet.send(args[:username])
  end
end

  注意,当你安装了zsh时候,执行下面命令会报错

 

rake tweets:seed[100,200]
zsh: no matches found: tweets:seed[100,200]

  因为zsh不能正确解析,所以需要这样操作

rake tweets:send\[cpytel\]

或者
rake 'tweets:send[cpytel]'

也可以在zsh的配置文件中添加 unsetopt nomatch 解决,在执行时使用

rake tweets:send[cpytel]

  

  

 

posted on 2015-09-11 15:07  c3tc3tc3t  阅读(320)  评论(0编辑  收藏  举报