Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

API: Search

yairgo edited this page Sep 14, 2010 · 19 revisions

columns local

The set of searchable columns. This list defaults to the textual database fields. Note that this does not include your associations. If you want to search on your associations you need to define the API: Column and add them to this set.

Example:


class UsersController < ActionController::Base
  active_scaffold :users do |config|
    config.columns[:roles].search_sql = 'roles.name'
    config.search.columns << :roles
  end
end

Example2 (PostgreSQL):


class UsersController < ActionController::Base
  active_scaffold :users do |config|
    config.columns[:roles].search_sql = 'roles.name||roles.company'
    config.search.columns << :roles
  end
end

full_text_search global local

A flag for whether the search should do full-text searching in the database (LIKE %?%) or assume that search tokens will match the beginning (LIKE ?%). Default is :true.

link global

The action link used to tie the Search box to the List table. See API: Action Link for the options on this setting.

For further configurations, see API: Column for search_ui settings.

custom_formats

Active scaffold supports html, js, json, yaml, and xml formats by default. If you need to add another mime type for search you can do it here. The format is then added to the default formats.

Examples:


  1. Add a column (virtual, probably)
    config.search.custom_formats << :pdf
    or
    config.search.custom_formats = [:pdf]

Clone this wiki locally