How do you pass arguments to a rake task in RubyMine 3.0?
The situation
I have a rake task similar to
desc "A rake Task"
task :give_me_gold, [:quantity,:quality] => :environment do |task, args|
....
end
I am aware from the commandline you type
rake give_me_gold[10,24]
to pass parameters to the rake task. However when RubyMine runs the task it runs it like开发者_C百科 this:
rake give_me_gold[quantity,quality] --trace 10,24
Steps to reproduce
- Create a rake task that takes arguments.
- Have RubyMine installed version 3.0
- From RubyMine, click Tools -> Run Rake Task
- Input your rake task name. It should show up as "task[option,option]" and press enter
- A dialog will show up and ask for arguments. Fill it in and press enter
- Observe the command RubyMine runs.
Back to my question
How do you pass arguments to a rake task in RubyMine 3.0?
Thank you for taking the time to view this question
This is a bug in RubyMine. See Issue #8527 at jetbrains.net
task :give_me_gold do
quantity = ENV['quantity']
quality = ENV['quality']
puts "quantity: #{quantity}, quality: #{quality}"
end
rake give_me_gold quantity=10 quality=24
#=> quantity: 10, quality: 24
upd
task :give_me_gold, :quantity, :quality do |t, args|
puts "Args were: #{args}"
quantity = args['quantity']
quality = args['quality']
puts "quantity: #{quantity}, quality: #{quality}"
end
rake give_me_gold[10,24]
#=> quantity: 10, quality: 24
The good approach to pass inputs along with environment is:
**task :upload, [:path] => [:environment] do |t, args|
puts args
YOUR_MODEL.method(args)
end **
精彩评论