Skip to content
Advertisement

How to sanitize Arel SQL?

I have the following Arel SQL:

I get SQL Injection warning when I run brakeman. I tried the following:

However, I get the following error:

How do I sanitize sql statement with Arel?

Advertisement

Answer

I am answering my own question. I am using Arel following the Github wiki for Ransack gem. I was doing something very similar to point # 2.2 mentioned on doc: https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers. In order to sanitize the params and avoid brakeman sql injection warning, I ended up doing the following:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement