Project

General

Profile

Defect #1421 ยป patch_acts_as_searchable.patch

Pierre Paysant-Le Roux, 2008-06-10 21:56

View differences:

vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb (working copy)
27 27
          return if self.included_modules.include?(Redmine::Acts::Searchable::InstanceMethods)
28 28
  
29 29
          cattr_accessor :searchable_options
30
          self.searchable_options = options
30
 
31
          self.searchable_options = { :project_key => "project_id", :date_column => "created_on"}
32
          searchable_options.update(options) if options.is_a?(Hash)
31 33

  
32 34
          if searchable_options[:columns].nil?
33 35
            raise 'No searchable column defined.'
......
35 37
            searchable_options[:columns] = [] << searchable_options[:columns]
36 38
          end
37 39

  
38
          if searchable_options[:project_key]
39
          elsif column_names.include?('project_id')
40
            searchable_options[:project_key] = "#{table_name}.project_id"
41
          else
42
            raise 'No project key defined.'
43
          end
44
          
45
          if searchable_options[:date_column]
46
          elsif column_names.include?('created_on')
47
            searchable_options[:date_column] = "#{table_name}.created_on"
48
          else
49
            raise 'No date column defined defined.'
50
          end
51
          
52 40
          # Permission needed to search this model
53 41
          searchable_options[:permission] = "view_#{self.name.underscore.pluralize}".to_sym unless searchable_options.has_key?(:permission)
54 42
          
    (1-1/1)