Module: SimpleFormPolymorphicAssociations::Model::AutocompleteConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/concerns/simple_form_polymorphic_associations/model/autocomplete_concern.rb
Overview
Example:
# app/models/person.rb
class Person < ActiveRecord::Base
include SimpleFormPolymorphicAssociations::AutocompleteConcern
autocomplete scope: ->(matcher) { where("people.firstname LIKE :term", term: "%#{matcher.downcase}%") }, id_method: :id, text_method: :human
end
Instance Method Summary collapse
Instance Method Details
#as_autocomplete_json ⇒ Object
25 26 27 |
# File 'app/concerns/simple_form_polymorphic_associations/model/autocomplete_concern.rb', line 25 def as_autocomplete_json { id: send(self.class.[:id_method]), text: send(self.class.[:text_method]) } end |