[ ruby ] Net:Http Post

uri = URI('http://www.example.com/todo.cgi')
req = Net::HTTP::Post.new(uri)
req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31')

res = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end

case res
when Net::HTTPSuccess, Net::HTTPRedirection
# OK
else
res.value
end

ref : https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html

[ rake ] writing own rake task

lib/tasks/app/ns1.rake

namespace :app do

namespace :ns1 do
desc "TODO"
task :my_task_name1 => :environment do
end

desc "TODO"
task :my_task_name2, [:var1, :var2 ]=> :environment do

var1 = args[:var1] || 1.month.ago.beginning_of_day
end
end

end 

Execute

rake app:ns1:my_task_name1