Issue with upgrading to Rails 5 - before filter
Asked Answered
D

2

14

I know that before_filter is deprecated with rails. I'm not calling it but for some reason I'm getting a message that is saying I am. before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <top (required)> at /Users/intern/Desktop/Work/app/config/environment.rb:5)

In that file environment.rb on line 5 I'm not calling before filter but this line Rails.application.initialize!

Why would it be saying that a before filter is being used when it's not being called there? Any help would be great! Thanks.

Deadradeadweight answered 22/9, 2016 at 19:43 Comment(0)
E
27

One of the gems is using it. Or you, in other controllers. Replace all your usages of before_filter to before_action and pray that all your gems are maintained enough to do the same before this becomes an error.

Elodea answered 22/9, 2016 at 19:47 Comment(7)
So, when Rails is called that is calling all my gems and code?Deadradeadweight
Because my I'm not using it in my project and no gem is using to my knowledge.Deadradeadweight
Initializing the application does mean loading your gems, yes.Elodea
Okay, I see. ThanksDeadradeadweight
Do you know of a way I can find out which gem may be using it?Deadradeadweight
You can pry them open one by one by using bundle open gemname. Not the most efficient way, certainly.Elodea
Yikes yeah...That's good to know though. Thanks for the help.Deadradeadweight
P
5

You can find offending gems files using this snippet. Replace the path with your own gempath.

grep -rn --color=always --include=*.rb "[\.|\:|\s]before_filter " ~/.rvm/gems/ruby-2.5.1/gems 
Pincushion answered 30/4, 2018 at 22:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.