Skip to content

Instantly share code, notes, and snippets.

@workmaster2n
Last active December 25, 2015 07:59
Show Gist options
  • Save workmaster2n/6942912 to your computer and use it in GitHub Desktop.
Save workmaster2n/6942912 to your computer and use it in GitHub Desktop.
sanitize custom sql
ActiveRecord::Base.connection.execute("SELECT * FROM tracked_points, rules WHERE (tracked_points.id = 1 AND rules.id = 1) OR (tracked_points.id = 1 AND rules.id = 2)")
def search(tp_id1, rule_id1, tp_id2, rule_id2)
ActiveRecord::Base.connection.execute("SELECT * FROM tracked_points, rules WHERE (tracked_points.id = #{tp_id1} AND rules.id = #{rule_id1}) OR (tracked_points.id = #{tp_id2} AND rules.id = #{rule_id2})")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment