Configuring search options
Once acts_as_event
has been implemented, we can finish preparing our model by implementing acts_as_searchable
.
As with all previous internal plugins, the class extension needs to be included in the model we will be making searchable.
class KbArticle < ActiveRecord::Base validates :title, :presence => true validates :category_id, :presence => true # .. acts_as_searchable :columns => [ "#{table_name}.title", "#{table_name}.content"], :include => [ :project ], :order_column => "#{table_name}.id", :date_column => "#{table_name}.created_at" # .. end
This example allows our article model to be incorporated into Redmine's default search infrastructure, with article titles and the article contents being used as searchable targets.
The acts_as_searchable
plugin takes a number of optional values in the form of a hash. The most common values are as follows:
:columns
: This specifies...