API: Search - activescaffold/active_scaffold GitHub Wiki

action_group global local

Set this property so link is included in a group of links.

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
    config.columns[:user_type].search_ui = :select

    #to swap field_search and search
    config.actions.swap :search, :field_search
    config.field_search.link.parameters = {:kind => :field_search}
  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

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:

config.search.formats << :pdf
# or
config.search.formats = [:pdf]

full_text_search global local until v2.2

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.

Since v2.3 is replaced with text_search

link global local

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.

live global local v2.3+

Automatically submits the search conditions to the server as you type. This has an upside and a downside: it provides more feedback to the user (they can see the search working), but it can be inefficient with server resources.

reset_form global local v3.7.3+

When enabled, reset link will clear input fields in the search form, instead of refreshing the list without search and closing the form.

split_terms global local v2.4+

A string used to split the search string in terms. Default is ' '. Setting to nil disable splitting the search string.

text_search global local v2.3+

A flag for how the search should do full-text searching in the database:

  • :full (LIKE %?%)
  • :start (LIKE ?%)
  • :end (LIKE %?)
  • false (LIKE ?)

Default is :full.

⚠️ **GitHub.com Fallback** ⚠️