Commit 31491cc8480aa016111127d667f4ae56d2acd4f2
1 parent
faf02e35
Exists in
master
and in
29 other branches
Disable Solr for db:data:minimal task
Again, unlike acts_as_ferret, acts_as_solr doesn't work without the Solr server. So to avoid debian postinst script rake db:data:minimal to fail disable it.
Showing
2 changed files
with
13 additions
and
7 deletions
Show diff stats
Rakefile
@@ -7,4 +7,6 @@ require 'rake' | @@ -7,4 +7,6 @@ require 'rake' | ||
7 | require 'rake/testtask' | 7 | require 'rake/testtask' |
8 | require 'rake/rdoctask' | 8 | require 'rake/rdoctask' |
9 | 9 | ||
10 | +ACTS_AS_SEARCHABLE_ENABLED = false if Rake.application.top_level_tasks.detect{|t| t == 'db:data:minimal'} | ||
11 | + | ||
10 | require 'tasks/rails' | 12 | require 'tasks/rails' |
lib/acts_as_searchable.rb
1 | module ActsAsSearchable | 1 | module ActsAsSearchable |
2 | 2 | ||
3 | module ClassMethods | 3 | module ClassMethods |
4 | + ACTS_AS_SEARCHABLE_ENABLED = true unless defined? ACTS_AS_SEARCHABLE_ENABLED | ||
5 | + | ||
4 | def acts_as_searchable(options = {}) | 6 | def acts_as_searchable(options = {}) |
5 | - if (!options[:fields]) | ||
6 | - options[:additional_fields] |= [{:schema_name => :string}] | ||
7 | - else | ||
8 | - options[:fields] << {:schema_name => :string} | 7 | + if ACTS_AS_SEARCHABLE_ENABLED |
8 | + if (!options[:fields]) | ||
9 | + options[:additional_fields] |= [{:schema_name => :string}] | ||
10 | + else | ||
11 | + options[:fields] << {:schema_name => :string} | ||
12 | + end | ||
13 | + acts_as_solr options | ||
14 | + extend FindByContents | ||
15 | + send :include, InstanceMethods | ||
9 | end | 16 | end |
10 | - acts_as_solr options | ||
11 | - extend FindByContents | ||
12 | - send :include, InstanceMethods | ||
13 | end | 17 | end |
14 | 18 | ||
15 | module InstanceMethods | 19 | module InstanceMethods |