Search code examples
rubyautocompletewildcardhanami

Using hanami ORM to do autocomplete


I am trying to implement autocomplete with hanami-model and I am trying to find in documentation or google how fetch records using LIKE function.

I am trying to reflect following SQL query using hanami repositories:

SELECT * FROM users WHERE name LIKE '%a'

Do you know how to do this? Thanks for all answers.


Solution

  • Pavel is right, you can use repo.where { name.like(pattern) } code for work with LIKE/ILIKE.

    Here you can find real example :)