Save 36% for Black Friday! Learn more

New Discussion

Notifications

You’re not receiving notifications from this thread.

How we can use Like queries for searching on encrypted data? I used default Active Record Encryption

0
Databases

class Propose < ApplicationRecord
encrypts :email, :phone_number, :name, deterministic: true

scope :search_filter, -> (params) do
if params[:keyword].present?
where(search_filter_query, "%#{params[:keyword]}%", "%#{params[:keyword]}%", "%#{params[:keyword]}%", "%#{params[:keyword]}%", "%#{params[:keyword]}%").distinct
else
all
end
end

def self.search_filter_query
<<-SQL
proposes.email like ? or
proposes.first_name like ? or
proposes.last_name like ? or
proposes.phone_number like ?

SQL
end
end

this is my code when I send in "some text" in params[:keyword] I always get empty [] and data with that text is existing in my database.

Join the discussion
Create an account Log in