I have to perform a search on a database using ransack. A few columns in the database have data stored in serialized arrays. I want to match the exact data stored in the arrays with data sent by user to perform search (users' data are also arrays). For example, in database, one column has data as (c1
, c2
are test cases):
c1.column_data = [1, 2, 3, 4, 5]
c2.column_data = []
User searches for data (t1
, t2
, t3
are test cases):
t1.user_data = [1]
t2.user_data = [1, 3]
t3.user_data = [1, 2, 3, 4, 5]
t4.user_data = []
- For case
c1
witht1
,t2
,t4
, it should returnno match found
. - With
t3
, it should result withmatch found
. - For case
c2
witht1
,t2
,t3
, it should returnno match found
. - With
t4
, it return `match found.
I found postgres_ext gem, but I cannot make it work. Can anyone suggest how I can do this or suggest any alternative method for search like this? Any alternative solution is also welcome.
t2
onc1
), right? – Dore