1. Install the ferret gem
2. Tell the rails app where to find the gem:
# config/environment.rb
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
||= 'production'
if == 'production'
= '/home/forfolks/gems:/usr/lib/ruby/gems/1.8'
endIt seems that it is necessary to do this in environment.rb and not in config/environments/production.rb.
3. On shared hosting you can't run daemons so the DRb server approach for updating the ferret index won't work. I followed instructions here to set up a rake tast to update the index instead. I also commented out the production part in config/ferret_server.yml.
# app/models/product.rb
# disable automatic ferret indexing...move it to a cron job
self.disable_ferret(:always)
end# ferret_index.rake
desc "Updates the ferret index for the application."
task :ferret_index => [ :environment ] do | t |
Product.rebuild_index
# here I could add other model index rebuilds
puts "Completed Ferret Index Rebuild"
endI then call this in my code via:
system "rake ferret_index &"as detailed in this railscast.
No comments:
Post a Comment