tanin47/whowish_word — pull request #1 by wheeyls (2013-05-07 19:52:30+00:00)
Title: Updating change_word action to defer to a swappable service

Hi there! I saw your lightning talk at RailsConf and was inspired to try this gem out.

I was looking to use this on my Heroku project, and so using a writable flat file is out of the question.

To deal with this, I split the logic to save the translations out under

/lib/whowish_word/backends/flat_file_store.rb

And now the backend is swappable in the initializer:

WhowishWord.backend = WhowishWord::Backends::DeferToI18n

DeferToI18n just uses store_translation directly, so that I can use my redis server for the translations. I got this technique from Ryan Bates:

http://railscasts.com/episodes/256-i18n-backends?view=asciicast

I've written a few specs for this, I'll probably do more later. Also, I plan to have this live on my project in a week or two, so I'll let you know how it works.