0

I am using ror framework to generate a rest api with PostgreSQl as a database. I have a table with the following structure: orders id: uuid code: int8

Rows: 1 1000000045

So, the above row should be selected when the user types in either 45 or 4. How can I do that ? The ror code that I am trying with is as below:

scope :by_code_number, lambda { |code_number|
    where(code_number: code_number)
}

How can we achieve this using ror with postgresql. Is this possible with int8 datatype for the column or is only possible with String datatype.

Thanks

Ashy Ashcsi
  • 1,529
  • 7
  • 22
  • 54
  • it's only possible with strings, but you can cast your int8 to a string and then use LIKE to search for it. See https://stackoverflow.com/a/1684312/4473406 – Siim Liiser Oct 08 '20 at 10:53
  • Fastest way, use PgSearch https://github.com/Casecommons/pg_search ; it will take care of all of these issues – Roc Khalil Oct 08 '20 at 11:47

0 Answers0