Created
January 11, 2018 12:59
-
-
Save Nursultan91/bae8ddeaa259b7f82bf6eac79f22a035 to your computer and use it in GitHub Desktop.
Вот модель клиента
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Client < ActiveRecord::Base | |
belongs_to :user | |
has_many :call_center_touches | |
has_many :support_touches | |
has_many :sales_touches | |
has_many :client_events | |
has_many :events, through: :client_events | |
def self.text_search(query) | |
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") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment