There is a good way to implement a spellchecker in Ruby on Rails across the gem raspell that uses the dictionary of aspell to work, and here I let you a quick way to implement it.
First we install aspell (http://www.aspell.net):
Mac:
sudo port install aspell aspell-dict-en
Ubuntu:
sudo apt-get install aspell libaspell-dev aspell-en
After that we install the gem.
Mac:
sudo gem install raspell –with-opt-dir=/opt/local
Ubuntu:
sudo gem install raspell
With this you have now the possibility to spellcheck words in your application.
And that’s it, you could use it in a simple way like this:
require ‘rubygems’
require ‘raspell’
speller = Aspell.new(‘en-US’)
speller.suggestion_mode = Aspell::NORMAL
word = “haert”
if !speller.check(word)
#word is wrong
speller.suggest(word).first
end
You could have more information in the github repository: https://github.com/jimneath/raspell.