I am facing such problem in which 's is present in data. while searching it does not shows data. I wanna remove SQL injection issue Code ::
@search_condition = ""
if !search_text.nil?
search_field = search_text.split("-")
@search_condition = "( address_books.organization_name like '#{search_text}%' or address_books.business_name like '#{search_text}%' or address_books.federal_tax_id like '#{search_text}%' or address_books.city like '#{search_text}%' or address_books.zip like '#{search_text}%' ) " if search_field.length == 1
if search_text.include? "-"
if search_field.length <= 1
@search_condition = " ( address_books.organization_name like '%" + search_field[0] + "%' "
@search_condition += " or address_books.business_name like '%" + search_field[1] + "%' "
@search_condition += " or address_books.federal_tax_id like '%" + search_field[2] + "%' "
@search_condition += " or address_books.city like '%" + search_field[3] + "%' "
@search_condition += " or address_books.zip like '%" + search_field[4] + "%' ) "