Guest User

Untitled

a guest
Jan 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. class Client < ActiveRecord::Base
  2. belongs_to :user
  3. has_many :call_center_touches
  4. has_many :support_touches
  5. has_many :sales_touches
  6. has_many :client_events
  7. has_many :events, through: :client_events
  8.  
  9. def self.text_search(query)
  10. self.where("similarity(name, ?) > 0.2 OR similarity(iin, ?) > 0.2 OR similarity(email, ?) > 0.2 OR similarity(phone, ?) > 0.2" , query, query, query, query).order("similarity(name, #{ActiveRecord::Base.connection.quote(query)}) DESC")
  11. end
  12. end
Add Comment
Please, Sign In to add comment