Skip to content

Instantly share code, notes, and snippets.

View tfwright's full-sized avatar
🧿

T. Floyd Wright tfwright

🧿
View GitHub Profile
@tfwright
tfwright / tasks.rake
Created December 27, 2009 02:01
A collection of useful rake tasks that doesn't deserve real source control
namespace :db do
desc "Fetches records from the database and prints their attributes"
task :fetch, [:model, :conditions] => :environment do |t, args|
args.with_defaults(:conditions => "id = (SELECT MIN(id) from #{args.model.tableize})")
klass = args.model.classify.constantize
finder = (args.model.pluralize == args.model ? :all : :first)
records = klass.send(finder, :conditions => args.conditions)
puts records.to_yaml
end