Vishwani patlan
Joined
50 Experience
0 Lessons Completed
0 Questions Solved
Activity
Posted in How we can use Like queries for searching on encrypted data? I used default Active Record Encryption
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.