Skip to content

Instantly share code, notes, and snippets.

@Paxa
Created September 26, 2012 02:15
Show Gist options
  • Save Paxa/3785611 to your computer and use it in GitHub Desktop.
Save Paxa/3785611 to your computer and use it in GitHub Desktop.
Rails 2.3 gem rake-tasks loader
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'tasks/rails'
# Rails 2.3 dont load rake tasks from required gems
# this code will fix it
gem_tasks = []
Gem.loaded_specs.each do |name, spec|
next if %w{rake rails bundler activesupport rack actionpack actionmailer activerecord activeresource mysql2}.include?(name)
spec.load_paths.each do |load_path|
gem_tasks +=
Dir[File.join(load_path, '..', 'tasks', '*.rake')] +
Dir[File.join(load_path, 'tasks', '*.rake')]
end
end
gem_tasks.map {|f| load f }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment