How to check spelling in your rails app in three quick steps.

1. Install aspell (d’oh)

with desired dictionary/ies.

sudo apt-get install aspell aspell-en aspell-pl

2. Install ffi-aspell

(I can’t recommend respell as it’s quite dated and you probably will encounter some annoying utf-8 encoding problems)

3. Wake up

your inner grammar-nazi!

  speller = FFI::Aspell::Speller.new('en', encoding: 'utf-8')
  # you may be also interested in those two options for starter:
  # speller.set('ignore-case', 'true')
  # speller.suggestion_mode = 'normal'

  "I have no ideaz wut's goign on".gsub(/[\w\']+/) do |word|
    puts "'#{word}' seems incorrect, did you mean: '#{speller.suggestions(word).first}'?" unless speller.correct?(word)
  end
ideaz' seems incorrect, did you mean: 'ideas'?
'wut's' seems incorrect, did you mean: 'Wit's'?
'goign' seems incorrect, did you mean: 'going'?

It’s a nice feature that you can use eg. for suggesting/validating user’s search queries.