Skip to content

appearhere/globalize-versioning

 
 

Repository files navigation

Globalize Versioning Build Status

Introduction

globalize-versioning provides an interface between globalize and versioning gems such as PaperTrail.

At the moment, only paper_trail is supported, but support for other versioning gems is planned for the future. Pull requests are always welcome.

Installation

gem install globalize-versioning

When using bundler, add this line to your Gemfile:

gem 'globalize-versioning'

Usage

To add versioning support to your model, just add the :versioning option to your call to translates with the name of the versioning gem as its value. For example:

translates :title, :content, :published, :published_at, :versioning => :paper_trail

You will also need to have already generated the versions table that paper_trail expects. See the paper_trail README for more details.

To pass options to the versioning gem, replace the gem name with a hash, and include the options as the value of the :options key:

translates :title, :content, :published, :published_at, :versioning => { :gem => :paper_trail, :options => { :on => [ :update ] } }

To access versions of a translated model, use the format: post.translation.versions. Earlier versions of the globalize versioning support delegated version and versions to the model translation (so you could access them with just post.versions), but this causes problems if versioning is used on non-translated attributes, and has thus been removed.

Adding globalize versioning to previously versioned models

If you are adding globalize to any previously versioned models, please note that you will need to add a new locale column to your versioning table.

Other gotchas

Please see the tests in test/globalize-versioning/ for more details.

License

See LICENSE for details.

About

Versioning support for the Globalize library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%