Sha256: 7b94e3bfbbfff013f9e1fd2d7647ea519928157be722f8197aea0a37ec979d18
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
{<img src="https://badge.fury.io/rb/translatable_records.png" alt="Gem Version" />}[http://badge.fury.io/rb/translatable_records] {<img src="https://codeclimate.com/github/museways/translatable_records.png" />}[https://codeclimate.com/github/museways/translatable_records] {<img src="https://secure.travis-ci.org/museways/translatable_records.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/translatable_records] {<img src="https://gemnasium.com/museways/translatable_records.png" alt="Dependency Status" />}[https://gemnasium.com/museways/translatable_records] = Translatable Records Everything you need to work with translatable records. = Install Put this line in your Gemfile: gem 'translatable_records' Then bundle: $ bundle = Usage First define the model and set the name of the fields you want to translate with the attr_translatable method: attr_translatable :attr Generate the translation model and migration for that model: rails g translation Model Update the translation migration with the column for that field and remove the column from the original table: t.string :attr Update your db: rake db:migrate (Now you can use that field of the model as usual and any change would be saved using the current I18n.locale) If you want to change the locale to something different than I18n.locale: model_instance.with_locale :es If you want to build a translation for each available locale: model_instance.build_translations If you want to save multiple translations: <%= f.fields_for 'translations_attributes[]', t do |ff| %> <%= field_set_tag t("languages.#{t.locale}") do %> <% unless t.new_record? %> <%= ff.hidden_field :id %> <% end %> <%= ff.hidden_field :locale %> <li> <%= ff.label :attr %> <%= ff.text_field :attr %> </li> <% end %> <% end %>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translatable_records-1.0.7 | README.rdoc |