9
9
9karamba2019-04-15 10:21:31
Ruby on Rails
9karamba, 2019-04-15 10:21:31

How to search in rails like in js using a regular expression?

When I use WHERE, it looks in the description for exactly what I entered. And I want him to search for a certain word in the description and display the description in which he found this word. I didn't find anything on this topic, is it possible to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artur Bordenyuk, 2019-04-15
@HighQuality

MyModel.where("description LIKE ?", "%слово%")

B
blackst0ne, 2019-04-15
@blackst0ne

User.where("email LIKE :email", email: "%@example.com")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question