“rails/init.rb 已弃用”的向后兼容解决方案?
我使用的 Rails 插件 (google_analytics) 是为 Rails 2.3 编写的,包含一个名为rails/init.rb 的文件,在 Rails 3 下会产生警告:
DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated: /home/logankoester/hack/active/myapp/vendor/plugins/google_analytics/rails/init.rb. (called from <top (required)> at /home/logankoester/hack/active/myapp/config/environment.rb:5)
现在,我可以简单地移动我的 fork 中的文件,但我不认为这会与 Rails 2 向后兼容。是否有针对此更改的解决方案适用于两个版本,或者我是否必须为 Rails 的每个主要版本维护单独的分支?
A Rails plugin I use (google_analytics) that was written for Rails 2.3 contains a file called rails/init.rb, which under Rails 3 yields the warning:
DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated: /home/logankoester/hack/active/myapp/vendor/plugins/google_analytics/rails/init.rb. (called from <top (required)> at /home/logankoester/hack/active/myapp/config/environment.rb:5)
Now, I could simply move the file in my fork, but I don't expect this would be backwards-compatible with Rails 2. Is there a solution to this change that would work for both versions, or will I have to maintain separate branches for each major version of Rails?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将其重写为 gem 并捆绑它。这也适用于 Rails 2。
Try to rewrite it to a gem and bundle it. That would work for Rails 2 as well.