In your controller
def get_autocomplete_items(parameters)
items = active_record_get_autocomplete_items(parameters)
items = items.where(searchable: true)
end
In the example above we call active_record_get_autocomplete_items
rather than super
; there is no super as these methods are called dynamically due to the design to handle multiple ORMs. In the above example ActiveRecord
is assumed, however Mongoid
and MongoMapper
are also both currently supported (as others may be in the future). The example above will still work, but depending on the ORM you are using the call to active_record_get_autocomplete_items(parameters)
would need to change to match your driver, for example it would become mongo_mapper_get_autocomplete_items(parameters)
for the MongoMapper
driver.
Using scope
autocomplete :hotel, :hotel_name, :full => true, :scopes => [:searchable_allow]
In model
scope :searchable_allow, where(searchable: true)