diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-01-14 19:00:19 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-03-10 10:13:25 +0000 |
commit | 01dd220d34cbd84ec0d02f0533d82d9af7c8a913 (patch) | |
tree | 710d4b7a66146860ab8da9cce48abed897aa7c98 /db/migrate/096_create_translation_tables.rb | |
parent | 33f463d602f69893a1ee2587ceac337d89c2210e (diff) |
initial support for localising model data (not fully tested)
Diffstat (limited to 'db/migrate/096_create_translation_tables.rb')
-rw-r--r-- | db/migrate/096_create_translation_tables.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/db/migrate/096_create_translation_tables.rb b/db/migrate/096_create_translation_tables.rb new file mode 100644 index 000000000..9d7cc65ad --- /dev/null +++ b/db/migrate/096_create_translation_tables.rb @@ -0,0 +1,27 @@ +class CreateTranslationTables < ActiveRecord::Migration + def self.up + fields = {:name => :text, + :short_name => :text, + :request_email => :text, + :url_name => :text, + :notes => :text, + :first_letter => :string, + :publication_scheme => :text} + PublicBody.create_translation_table!(fields) + + # copy current values across to default locale + PublicBody.all.each do |publicbody| + publicbody.translated_attributes.each do |a, default| + value = publicbody.read_attribute(a) + unless value.nil? + publicbody.send(:"#{a}=", publicbody.read_attribute(a)) + end + end + end + end + + + def self.down + PublicBody.drop_translation_table! + end +end |