Back

Named sql interpolation

You can use string interpolation safely in your SQL queries with named parameters such as WHERE name = :first_name, rather than WHERE name = ?

When calling the query simply pass a hash to it.

MyModel.where(
  'first_name = :first_name AND last_name = :last_name',
  { first_name: 'John', last_name: 'Smith' }
)