Rails Refinery CMS I18n + globalize gem

Refinery cms allow you to add custom translations to your pages (see config/refinery/i18n.rb file).

But when you want to add translation table to existing engine model (for example Refinery::Articles::Article) do this:

rails g refinery:engine article name:string description:text photo:image --extension=articles --namespace articles --i18n name description

This code will create migration with translations table (in vendor/extensions/articles/db/migrations) and extend your model (translates name and description fields)
To copy this migration put this command:

rails g refinery:articles

Or you can do this manually, by moving your migration code to your_app/db/migrations/timestamp_crete_articles_articles.rb

P.S. If you got error when try to run your migration with text “can’t mass assignment write attribute locale”, create file globalize_locale.rb in your config/initializers directory with the following text:

Globalize::ActiveRecord::Translation.class_eval do
  attr_accessible :locale
end
Good luck!

Поделиться с друзьями

Френдинг

 

Comments

No comments so far.

Leave a Reply

 
(will not be published)
 
 
Comment