Cotswold Guesthouse
That site's at cotswold.co.za.
We wanted to create a guest house site with the text in various languages.
Since the people who were going to translate the site from english into [French|Italian|German] were going to be 'geographically distributed', and not likely available at the same time, I thought it would be too complex to coordinate all those translations and the updating of the site. Creating the site in rails as a CMS was the easiest way to deal with it. When someone is ready to add or translate text, they can login and do so.
Basic Ingredients: Rails and postgres, along with the globalize, file_column and exception_notification plugin.
Globalize Functional Test Failing
I added the globalize plugin to an application following some instructions on the web. There are quite a few sets of instructions out there, and nothing seems to be 'official'. Depending on what you use, you can run into difficulties.
My problem was with the functional tests. Running the tests, I get something like this:
88) Error:
test_index(ServicesControllerTest):
ActionController::RoutingError: No url can be generated for the hash {:controller=>"services", :action=>"index"}
...
... /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_process.rb:336:in `get'
./test/functional/services_controller_test.rb:18:in `test_index'
The problem is that there is no default route that the tests seem to find. All of that code that the instructions told me to put into environment.rb does not seem to set any default locale. I knew that adding locales to the tests in the controllers would work, but I was not ready to start changing every
get :index
to
get :index, :locale => 'en'
in every controller test. Way too much work.
What seemed to work for me was to set up a default route. I changed this:
map.connect ':locale/:controller/:action/:id'
to
map.connect ':locale/:controller/:action/:id', :defaults => { :locale => Globalize::Locale.language ? Globalize::Locale.language.code : 'en'}
and all was fine again.
Rails 2.0.0_PR and Globalize breakage 0
My functional tests broke when I went to Rails 2.0. It took a while to grok the stack trace:
ArgumentError: wrong number of arguments (2 for 1)
..../vendor/rails/activerecord/lib/active_record/base.rb:1965:in `attributes_with_quotes'
..../vendor/rails/activerecord/lib/active_record/base.rb:1965:in `update_without_lock'
Turns out the problem was that in Rails 2.0, ActiveRecord's 'attributeswithquotes' method now takes 2 arguments instead of a single one. The problem is that globalize overrides this method in the db_translate.rb, so things break.
It's easy to fix, though. Adding the extra argument to globalize's db_translate.rb seems to do fix what hurts.
