Class: Business

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/business.rb

Overview

Information about the Business that the service Provider runs.

Schema Information

Table name: businesses

id            :integer          not null, primary key
name          :string           default(""), not null
description   :string           default("")
location      :string           default(""), not null
business_type :string           default(""), not null
created_at    :datetime         not null
updated_at    :datetime         not null

Class Method Summary (collapse)

Class Method Details

+ (Object) search(business_search_form)



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/business.rb', line 17

def self.search business_search_form
  if business_search_form.valid?
    where(
      'name ILIKE :name AND location ILIKE :location AND business_type ILIKE :business_type',
      name: "%#{ business_search_form.name }%",
      location: "%#{ business_search_form.location }%",
      business_type: "%#{ business_search_form.business_type }%"
    )
  else
    none
  end
end