Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined method #sanitize for ActiveRecord::Base

I just upgraded to Rails 5.1.1 and am receiving this error.

NoMethodError (undefined method `sanitize' for ActiveRecord::Base:Class):

The stack traces back to this code

like_search_term = ActiveRecord::Base::sanitize("%#{escaped_search_term}%")

Has this method been removed or changed in the new Rails upgrade?

like image 866
William Holt Avatar asked Jun 15 '17 19:06

William Holt


1 Answers

Yes, indeed, it appears to be removed.

Sanitize was never part of the public API of the framework. As we didn't need it in the framework anymore, we removed. The recommended ways to sanitize raw SQL for use in execute statements were the public API for that http://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html

like image 196
Sergio Tulentsev Avatar answered Oct 17 '22 17:10

Sergio Tulentsev