Skip to content

Instantly share code, notes, and snippets.

@danieltahara
Created June 22, 2012 18:05
Show Gist options
  • Save danieltahara/2974276 to your computer and use it in GitHub Desktop.
Save danieltahara/2974276 to your computer and use it in GitHub Desktop.
practice rake file
task :greet do
puts "hello"
end
task :ask => [:greet, :question] do
puts "how are you?"
end
task :question do
puts "who are you?"
end
namespace :pick do
desc "picks a random user and prints email"
task :winner => :environment do
user = User.find(:first, :order => 'RAND()')
puts user.email
end
task :devices => :environment do
devices = User.find(:first, :order => 'RAND()').devices
puts devices
end
def pick(model_class)
model_calss.find(:first, :order => 'RAND()')
end
end
task :all => [:ask]
task :default => :all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment