未定义的方法#sanitize ActiveRecord :: Base [英] Undefined method #sanitize for ActiveRecord::Base
本文介绍了未定义的方法#sanitize ActiveRecord :: Base的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚升级到Rails 5.1.1,并收到此错误.
I just upgraded to Rails 5.1.1 and am receiving this error.
NoMethodError (undefined method `sanitize' for ActiveRecord::Base:Class):
堆栈可追溯到此代码
like_search_term = ActiveRecord::Base::sanitize("%#{escaped_search_term}%")
在新的Rails升级中是否已删除或更改了此方法?
Has this method been removed or changed in the new Rails upgrade?
推荐答案
是的,的确是
Sanitize从来不是该框架的公共API的一部分.由于我们不再需要框架中的内容,因此我们将其删除.推荐的清理原始SQL以便在执行语句中使用的方法是该 http的公共API. ://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html
这篇关于未定义的方法#sanitize ActiveRecord :: Base的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文