How to sanitize sql fragment in Rails

前端 未结 6 586
南方客
南方客 2021-02-01 13:28

I have to sanitize a part of sql query. I can do something like this:

class << ActiveRecord::Base
  public :sanitize_sql
end

str = ActiveRecord::Base.sani         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 14:32

    ActiveRecord::Base.connection.quote does the trick in Rails 3.x

提交回复
热议问题