Tyl*_*gan 2 ruby-on-rails sunspot sunspot-rails sunspot-solr ruby-on-rails-4
我正在尝试使用Rails 4的太阳黑子,我遇到了一些问题.当我只gem 'sunspot_rails', '2.0.0'在我的gemfile中时,我收到此错误:
Note: This task has been moved to the sunspot_solr gem. To install, start and
stop a local Solr instance, please add sunspot_solr to your Gemfile:
group :development do
gem 'sunspot_solr'
end
Run Code Online (Sandbox Code Playgroud)
但是,当我添加该gem(也是v 2.0.0)时,我收到此错误:
rake aborted!
Don't know how to build task 'sunspot:solr:start'
/home/toasty/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
/home/toasty/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
我已经看到了这个问题: 太阳黑子/ Solr raketasks没有加载Rails 3可安装引擎, 但它似乎在我的情况下不起作用.有没有人有任何想法?sunspot_solr与rails 4不兼容吗?
Alt*_*eez 12
我有同样的问题.我不记得了,但我发现你需要添加这个rake任务
lib/tasks/solr.rake
namespace :sunspot do
namespace :solr do
desc 'Start the Solr instance'
task :start => :environment do
case RUBY_PLATFORM
when /w(in)?32$/, /java$/
abort("This command is not supported on #{RUBY_PLATFORM}. " +
"Use rake sunspot:solr:run to run Solr in the foreground.")
end
if defined?(Sunspot::Rails::Server)
Sunspot::Rails::Server.new.start
else
Sunspot::Solr::Server.new.start
end
puts "Successfully started Solr ..."
end
desc 'Run the Solr instance in the foreground'
task :run => :environment do
if defined?(Sunspot::Rails::Server)
Sunspot::Rails::Server.new.run
else
Sunspot::Solr::Server.new.run
end
end
desc 'Stop the Solr instance'
task :stop => :environment do
case RUBY_PLATFORM
when /w(in)?32$/, /java$/
abort("This command is not supported on #{RUBY_PLATFORM}. " +
"Use rake sunspot:solr:run to run Solr in the foreground.")
end
if defined?(Sunspot::Rails::Server)
Sunspot::Rails::Server.new.stop
else
Sunspot::Solr::Server.new.stop
end
puts "Successfully stopped Solr ..."
end
# for backwards compatibility
task :reindex => :"sunspot:reindex"
end
end
Run Code Online (Sandbox Code Playgroud)
编辑~ Rakefile的来源