Posts tagged with " internationalization"

Globalize on Rails needs a quick patch…

Throughout my Rails journey I have come across a number of problems with various plugins. The globalize plugin is one which can completely localize an application through a database and some simple syntax. Chinese & English sites here I come…Anyhow during the install of Globalize for Rails 1.2 I came upon the following error and here is it’s solution if anyone needs it.

This has been tested on a fresh Globalize install on Debian, Rails 1.1, MySQL –version:
“mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (x86_64) using readline 5.2″

Error
================
** Execute globalize:create_tables rake aborted! Mysql::Error: #42000Identifier name ‘index_globalize_translations_on_table_name_and_item_id_and_language_id’ is too long: CREATE INDEX index_globalize_translations_on_table_name_and_item_id_and_language_id ON globalize_translations (table_name, item_id, language_id)
================

Cause
================
On Globalize Migration, line 32, an index to globalize_translations is created. However, this fails due to the index name being added as: add_index :globalize_translations, [ :table_name, :item_id, :language_id ]

… which in turn tries to create an index name of: index_globalize_translations_on_table_name_and_item_id_and_language_id

This is 70 characters, which exceeds the index identifier limit of 64 characters: http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
================

Solution
================
One solution is to rename the index name, in: globalize/generators/globalize/templates/migration.rb (migration.rb.gz:32 && tiny_migration.rb.gz:31)
…to:
add_index :globalize_translations, [ :table_name, :item_id, :language_id ], :name => ‘glb_trns_idx’
================

If this is double dutch to you then pay no heed, it will definitely help out some poor other misfortunate person and save them some much valuable time in the future.

2007-04-02 by Jonathan Clarke - Comments: 1 | New Comment