How to run rake tasks from console
- Rails.application.load_tasks
- Rake::Task['my_task'].invoke
Side notes:
You could use Rake::Task.task to show all the tasks in the console
Ref:
| require 'benchmark' | |
| n = 5 # Use any n you like | |
| Benchmark.bmbm do |x| | |
| x.report("find by") { | |
| n.times { User.find_by_name("Joe").id } | |
| } | |
| x.report("select") { | |
| n.times { User.find(:first, :select => :id, :conditions => ["name = ?","Joe"]).id } | |
| } |
How to run rake tasks from console
Side notes:
You could use Rake::Task.task to show all the tasks in the console
Ref:
| typeset -A newmap | |
| newmap[111111111111]="IAD-Alpha" | |
| newmap[222222222222]="IAD-Beta" | |
| # echo ${newmap[111111111111]} | |
| # for key ("${(@k)newmap}") printf 'key=%s value=%s\n' "$key" "$newmap[$key]" | |
| for key ("${(@k)newmap}") |