0
が、私はエラーを取得するレールMySQLエラーが
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%)
どのように私はこの問題を解決することができますか?
LOWER(reservations.message) LIKE '%booked%'
すなわち:あなたが生成したいSQLがあるので
モデル
scope :with_type, lambda { |type|
where("LOWER(reservations.message) LIKE %#{type}%")
}
サーバー
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)
ありがとうございます! – John