Issue with upgrading to Rails 5 - before filter

╄→尐↘猪︶ㄣ 提交于 2020-01-12 07:24:20

问题


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.


回答1:


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.




回答2:


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 


来源:https://stackoverflow.com/questions/39647644/issue-with-upgrading-to-rails-5-before-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!