Skip to content
dennisbulgatz edited this page Oct 26, 2010 · 30 revisions

The FieldSearch action is an advanced search. Provides a UI to allow specification of a value and operator for each searchable field. Text fields can be search using operators such as “Begins With”, “Ends With”, “Contains”, “=”, “>=”, etc.

columns local

The set of searchable columns. This list defaults to the textual database fields.

config.field_search.columns = :user_type, :widget_id, :name, :owner, :status

h2. formats

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

Examples:

config.field_search.formats << :pdf
# or
config.field_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.

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.

search_ui local

To customize the search form columns use search_ui similar to form_ui. Note that we can’t use a :checkbox search_ui because it’s not posible to determine wheater to search for that field or not (:checkbox will silently render a :select)

Examples:

Field Search Example (with drop down for user type)

class UsersController < ActionController::Base
  active_scaffold :users do |config|
     config.actions = [:nested, :list, :show, :field_search]
     config.columns[:user_type].search_ui = :select
  end
end

module UsersHelper
	# display the "user_type" field as a dropdown with options
	def user_type_search_column(record, input_name)
		select :record, :user_type, options_for_select(User.user_types), {:include_blank => as_('- select -')}, input_name
	end
end

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.

When a drop down (select) is used, sql will use LIKE with no wild cards, which is fast!

config.field_search.text_search = false
Clone this wiki locally