Class: Wco::Api::LeadsController
- Inherits:
-
Wco::ApiController
- Object
- Wco::ApiController
- Wco::Api::LeadsController
- Defined in:
- app/controllers/wco/api/leads_controller.rb
Instance Method Summary collapse
- #by_email ⇒ Object
-
#index ⇒ Object
select2-leads-ajax.
- #index_hash ⇒ Object
Instance Method Details
#by_email ⇒ Object
7 8 9 10 |
# File 'app/controllers/wco/api/leads_controller.rb', line 7 def by_email @lead = Wco::Lead.find_or_create_by_email( params[:email] ) render formats: [:json] end |
#index ⇒ Object
select2-leads-ajax
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/wco/api/leads_controller.rb', line 13 def index :index, Wco::Lead @leads = Wco::Lead.all if params[:q].present? q = params[:q].downcase @leads = @leads.any_of( { email: /#{q}/i }, { name: /#{q}/i }, ); end end |