Skip to content

Instantly share code, notes, and snippets.

@shaunoconnell
Created August 18, 2011 15:38
Show Gist options
  • Save shaunoconnell/1154345 to your computer and use it in GitHub Desktop.
Save shaunoconnell/1154345 to your computer and use it in GitHub Desktop.
rails rake task to override things. . .for legacy db where user does not have perms
# since we are using a "legacy" schema, we don't want to drop db or tables.'
Rake::TaskManager.class_eval do
def alias_task(fq_name)
new_name = "#{fq_name}:original"
@tasks[new_name] = @tasks.delete(fq_name)
end
end
def alias_task(fq_name)
Rake.application.alias_task(fq_name)
end
def override_task(*args, &block)
name, params, deps = Rake.application.resolve_args(args.dup)
fq_name = Rake.application.instance_variable_get(:@scope).dup.push(name).join(':')
alias_task(fq_name)
Rake::Task.define_task(*args, &block)
end
namespace :db do
namespace :test do
override_task :purge => :environment do
puts ".... nada"
#ActiveRecord::Migrator.migrate("db/migrate/", 0)
end
end
namespace :schema do
override_task :load => :environment do
puts "should be loaded already."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment