spaghetticode / rails2ext

Useful extensions for rails 2.3.x
2 stars 0 forks source link

Silence Rubygems 1.8 deprecations #1

Open elia opened 12 years ago

elia commented 12 years ago

including the following code after Rails.boot! in config/boot.rb in conjunction with Bundler will silence those annoying deprecations :)

# Silence rubygems deprecations
if Gem::VERSION.to_f >= 1.8
  require 'rails/gem_dependency'

  class Rails::GemDependency
    def self.add_frozen_gem_path
      @@paths_loaded ||= begin
        original_source_index = Gem::Specification.respond_to?(:dirs) ? Gem::SourceIndex.new(Gem::Specification.dirs) : Gem.source_index
        source_index = Rails::VendorGemSourceIndex.new(original_source_index)
        Gem.clear_paths
        Gem.source_index = source_index
        # loaded before us - we can't change them, so mark them
        Gem.loaded_specs.each do |name, spec|
          @@framework_gems[name] = spec
        end
        true
      end
    end
  end
end

Maybe it can become Rails.silence_rubygems_18up_deprecations!

spaghetticode commented 12 years ago

This is definitely something that should be added. Thanks for the suggestion