Module: Redmine::Search::Controller::ClassMethods

Defined in:
lib/redmine/search.rb

Constant Summary collapse

@@default_search_scopes =
Hash.new {|hash, key| hash[key] = {:default => nil, :actions => {}}}

Instance Method Summary collapse

Instance Method Details

#default_search_scope(id, options = {}) ⇒ Object

Set the default search scope for a controller or specific actions Examples:

* search_scope :issues # => sets the search scope to :issues for the whole controller
* search_scope :issues, :only => :index
* search_scope :issues, :only => [:index, :show]


160
161
162
163
164
165
166
167
# File 'lib/redmine/search.rb', line 160

def default_search_scope(id, options = {})
  if actions = options[:only]
    actions = [] << actions unless actions.is_a?(Array)
    actions.each {|a| default_search_scopes[controller_name.to_sym][:actions][a.to_sym] = id.to_s}
  else
    default_search_scopes[controller_name.to_sym][:default] = id.to_s
  end
end