Dimitar Kostov ramblings

Passing arguments to rake task

Rakefile
1
2
3
4
5
6
7
namespace :log do
  desc 'Upload logfile to cloud-based server'
  task :upload, [:filename] => [:environment] do |t, args|
    # upload logic
    # args[:filename] is the passed argument
  end
end
$ rake log:upload[development.log]

# If the shell complains just escape the brackets

$ rake log:upload\[development.log\]

Comments