Class: MySearch
- Inherits:
-
Object
- Object
- MySearch
- Defined in:
- lib/mysearch.rb
Class Method Summary collapse
- .booking(attributes, keyword) ⇒ Object
- .flight(attributes, keyword) ⇒ Object
- .hotel(attributes, keyword) ⇒ Object
- .user(attributes, keyword) ⇒ Object
Class Method Details
.booking(attributes, keyword) ⇒ Object
3 4 5 6 |
# File 'lib/mysearch.rb', line 3 def self.booking(attributes, keyword) query_attrs = attributes.map { |a| "#{a.to_s}::TEXT ILIKE '%#{keyword}%'"}.join(' OR ') Booking.where(query_attrs) end |
.flight(attributes, keyword) ⇒ Object
14 15 16 17 |
# File 'lib/mysearch.rb', line 14 def self.flight(attributes, keyword) query_attrs = attributes.map { |a| "#{a.to_s}::TEXT ILIKE '%#{keyword}%'"}.join(' OR ') Flight.where(query_attrs) end |
.hotel(attributes, keyword) ⇒ Object
19 20 21 22 |
# File 'lib/mysearch.rb', line 19 def self.hotel(attributes, keyword) query_attrs = attributes.map { |a| "#{a.to_s}::TEXT ILIKE '%#{keyword}%'"}.join(' OR ') Hotel.where(query_attrs) end |
.user(attributes, keyword) ⇒ Object
8 9 10 11 12 |
# File 'lib/mysearch.rb', line 8 def self.user(attributes, keyword) query_attrs = attributes.map { |a| "#{a.to_s}::TEXT ILIKE '%#{keyword}%'"}.join(' OR ') puts query_attrs User.where(query_attrs) end |