Class: ClientEngine::Client
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ClientEngine::Client
- Defined in:
- app/models/client_engine/client.rb
Class Method Summary collapse
-
.search(term) ⇒ Object
Metodo de busqueda de clientes por nombre, apellido o documento.
Instance Method Summary collapse
Class Method Details
.search(term) ⇒ Object
Metodo de busqueda de clientes por nombre, apellido o documento
20 21 22 23 24 25 26 |
# File 'app/models/client_engine/client.rb', line 20 def self.search term if term where("LOWER(client_engine_clients.first_name || ' ' || client_engine_clients.last_name) LIKE LOWER(?) OR client_engine_clients.document LIKE ?", "%#{term}%", "%#{term}%") else all end end |
Instance Method Details
#address ⇒ Object
11 12 13 |
# File 'app/models/client_engine/client.rb', line 11 def address read_attribute(:address).titleize unless read_attribute(:address).nil? end |
#full_address ⇒ Object
15 16 17 |
# File 'app/models/client_engine/client.rb', line 15 def full_address "#{address}. - #{locality.titleize} - #{city.titleize} - #{country.titleize}" end |
#name ⇒ Object
7 8 9 |
# File 'app/models/client_engine/client.rb', line 7 def name "#{last_name.titleize}, #{first_name.titleize}" end |