lassebunk / gretel

Flexible Ruby on Rails breadcrumbs plugin.
MIT License
889 stars 114 forks source link

alias_method_chain is deprecated in Rails 5 #65

Closed craig1410 closed 8 years ago

craig1410 commented 8 years ago

When booting up my rails app either via rake test or rails server, I get 3 deprecation warnings as follows:

DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <top (required)> at /Users/craig/Development/LW/mm2/config/application.rb:7)

The line failing is:

Bundler.require(*Rails.groups)

Upon debugging I found these warnings were issued during the loading of the gretel gem and on reviewing the code I found 3 places where alias_method_chain is called. I have created a pull request which seems to work in Ruby 1.9.3 through 2.2.3. I'll post the PR in a moment and would appreciate any feedback.

acrolink commented 8 years ago

@craig1410 Would you please explain how to debug this in order to find which gem is causing the warnings?

craig1410 commented 8 years ago

@acrolink It was a few months ago when I did this but I think I just used my RubyMine IDE debugger tools to step into the code and framework and eventually by interrogating the variables during loading of gems I found the gem responsible. Sorry I can't be more specific and I'm sure there are better ways to do this but I'm pretty sure this is what I did.

Hope this helps, Craig.

acrolink commented 8 years ago

Thanks @craig1410 I will give that a try.

aried3r commented 8 years ago

Any plans for a release with this change? Since Rails 5 is out and all :)

WilHall commented 8 years ago

@aried3r Yes, hopefully in another week or so.

ktec commented 8 years ago

Anyone coming here, I found adding a little debug to the rails file ...gems/railties-5.0.0/lib/rails/initializable.rb was enough to point me in the right direction....

    def run_initializers(group=:default, *args)
      return if instance_variable_defined?(:@ran)
      initializers.tsort_each do |initializer|
        puts "Initializer: #{initializer.name}"   <<<<<<<<<<<<<< HERE
        initializer.run(*args) if initializer.belongs_to?(group)
      end
      @ran = true
    end
acrolink commented 8 years ago

@ktec Thanks, I will try the method you had suggested later and report back.

alecrubin commented 7 years ago

@WilHall @aried3r any updates on resolving this issue?

kevinelliott commented 7 years ago

I'm also curious about how to resolve this.

aried3r commented 7 years ago

This has been fixed in 3.0.9 I believe, see https://github.com/lassebunk/gretel/blob/v3.0.9/lib/gretel/deprecated/show_root_alone.rb