简体   繁体   English

如何使用named_scope(rails 2.X)/ scope(rails 3)避免过时警告class_method

[英]How to avoid deprecation warning with named_scope (rails 2.X) / scope (rails 3) class_method

I build several plugins using the class method 'named_scope', which has been deprecated and replaced by 'scope' in Rails 3. I would like to avoid the following warning as I have lot a scopes present in my plugins : 我使用类方法“ named_scope”构建了多个插件,在Rails 3中,该方法已被弃用并替换为“ scope”。我想避免以下警告,因为我的插件中存在很多作用域:

DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead.

How to you deal with that? 您如何处理? Did you create any 'scope' method if it's rails 2.X and pass the information to 'named_scope'? 如果是rails 2.X,是否创建了任何“ scope”方法并将信息传递给“ named_scope”? Any clean suggestion? 有什么干净的建议吗?

Cheers! 干杯!

Vincent 文森特

唯一真正的解决办法是修复输出此错误的实际插件。

只需将named_scope更改为您在何处调用的范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM