I get an error
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%booked%)
How can I solve this?
Model
scope :with_type, lambda { |type|
where("LOWER(reservations.message) LIKE %#{type}%")
}
Sql statement on server
SELECT `reservations`.*
FROM `reservations`
LEFT OUTER JOIN `users` ON `users`.`id` = `reservations`.`from_id`
WHERE (`users`.`access_level_id` != 1)
AND `reservations`.`id_to` IS NULL
AND (LOWER(reservations.message) LIKE %booked%)
ORDER BY reservations.created_at desc LIMIT 10 OFFSET 0)