Archive for July, 2006|Monthly archive page

Search problems

In my last post I said that I was using acts_as_ferret.  However I was finding it difficult to create an index for a certain section of the site.  I think this was due to me having null fields some of the database fields. I could nt change this.

When I was having problems I turned to acts_as_searchable. As the post states the search plugin uses HyperEstraier which is an opensource search engine.  It seems to be very good and above all (for me) the UTF support seems excellent. This is demenstroated by having a Japenese language search demo on their site.

I managed to get it to work 🙂 I will post how in the next couple of days.

My first thoughs about HyperEstraier is that it has some very good features, but most of the features I am not going to use in the near future.  Overall the set up is a bit more invloved then ferret, this is because you need to run a deamon.

More thoughts soon!




I started using the acts_as_ferret plugin for ruby on rails today. I had a a few issues, so here is how I solved them.

  1. script/plugin install svn:// does not work! – After successfully installing ferret using the gem, I tried to download the plugin, but my box could not connect. I am not sure if it is an error with my setup or what. So I had to browse the source tree in track and copy and past the files on my box.
  2. Rails will not start – After I copied across the plugin, Rails was complaining that it could not find the plugin acts_as_ferret. It turned out that the plugin directory I had made was not world readable, so rails could not read it. A quick chmod fixed that
  3. Site was not getting indexed – After putting the acts_as_ferret in the desired models, I searched for words that I knew existed and i was not getting any responses. I figured out that it was not being indexed. if the index directory does not exist than the plugin calls rebuild_index method. This is supposed to go through your database and create the index. The app was failing executing the rebuild_index method. I googled the error and came across this post It was an error because i was using Unicode. So I added the following to my environment.rb file and it has indexed the files :

ENV[‘LANG’] = ‘en_GB.UTF-8’

ENV[‘LC_TIME’] = ‘C’

All I have to do now is figure out how to use ferret 🙂



I needed a way to send emails to users if certain data in the system had not been updated for 4 hours.

I thought that RailsCron would be the best solution developed by Kyle Maxwell. Unfortunatly his site and wiki was down. So I could not see how to use it correctly, as the readme was a bit vauge. So I thought I would post some simple code here to help some people on how to use RailsCron.

First of all I wanted to use ActsAsBackground on a Model Class. Here is the code :

class Comment < ActiveRecord::Base
  # This is the key thing.  I am not sure why it does not use acts_as_background
  include ActsAsBackground
  # This defines what method you want to use
  background :deliver, :every => 1.minute

def self.deliver
   #code here

What I was confused on was how to use acts as background. I managed to find a cached version of Kyle’s page and see it in action. I am sure there is a reason that it is not acts_as_background and why you need the include directive.

The next thing took me a while to figure out as well :). To actually use RaisCron you need to start it with a rake command like so :

rake cron_start

The rest of the comands are in the readme file. I hope this helps someone out there.