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]

51
52
53
54
55
56
57
58
# File 'lib/redmine/search.rb', line 51

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