globalize / globalize-versioning Goto Github PK
View Code? Open in Web Editor NEWVersioning support for the Globalize library
License: MIT License
Versioning support for the Globalize library
License: MIT License
Are there any plans for update so newest rails versions are supported?
Using Rails 4, Ruby 2.0.0p353, Globalize 4.0.0, paper_trail 3.0.0, master of globalize-versioning.
Product Model
class Product < ActiveRecord::Base
has_paper_trail :ignore => [:updated_at]
translates :title, :versioning => :paper_trail
end
Product Translation Model
class Product::Translation < ActiveRecord::Base
#This issue is present regardless of whether
#this line is present but product.translation.versions
# will be undefined if its not defined here
has_paper_trail
end
p = Product.create! title: "A"
p.translation.title
=> "A"
p.title
=> "A"
p.versions.count
=> 2 #This should be 1 right?
p.translation.versions.count
=> 1
#####Update a translation field
p.update!(title: "B")
p.title
=> "B"
p.previous_version.title
=> "B" #This should be 'A' right?
p.translation.previous_version.title
=> "A"
To summarize for translation fields, the updated value 'B' is being saved to the version table instead of the previous version. All non-translation fields are following this behavior correctly.
I saw your post that said "The syntax has changed somewhat: you have to call post.translation.versions now instead of just post.versions", but the issue is that
p.previous_version != p.translation.previous_version
=> true
because the model is partially translated. There are other fields in the product table that are not part of the product_translations table because they do not require translation...
Is there a way to set a custom paper trail class for versions?
I'm upgrading to rails 6.1. Looking through the commit history, it looks safe enough.
I am having the exact same issue as mentioned here:
I managed to fix the problem by following the advice, and creating a migration to add 'locale' to the versions table.
Perhaps there is a proper fix, or perhaps I have done something wrong?
To anyone who's coming here from Globalize: we're extracting versioning functionality into this new gem. We had considered creating two gems, one for paper_trail
and one for vestal_versions
, but in the end it seems easier to start with one gem, and just get the stuff out of core asap.
I've incorporated @robotvert's fix (#1) and added models and data to get the versioning tests from Globalize to work. I've also created branches for AR3 and AR4 with versioning support removed, and started writing up a basic roadmap in the Wiki.
The basic idea is: test against the "gutted" versions of AR3/AR4, and once we have something that looks workable, we can release this gem and new gutted versions of Globalize 3.0.x and 4.0.x, with a post install message warning users to add the globalize-versioning
gem if they want to continue using versioning.
But we still need to decide what interface we want to use (i.e. what option should be passed in to translates
to select the versioning gem, do has_paper_trail
and translates
have to be called in the correct order, etc.). @etagwerker has proposed some changes to get versioning working in 3.0.x in globalize/globalize#298, which we could incorporate here.
I don't use paper_trail
or vestal_versions
myself so I feel a bit out my comfort zone with this stuff (and I think @parndt is the same) which is part of the reason we have not moved very quickly on this issue. But obviously a lot of people want to use these gems together, so I'd like to focus discussion in this issue and other issues on this gem rather than in Globalize.
Shout out to: globalize/globalize#272, globalize/globalize#221, globalize/globalize#206 and globalize/globalize#117.
because of this, in paper_trail
# Set all the attributes in this version on the model
attrs.each do |k, v|
if model.has_attribute?(k)
model[k.to_sym] = v
else
logger.warn "Attribute #{k} does not exist on #{item_type} (Version id: #{id})."
end
end
I had to patch my translated model to do this
def has_attribute?(att)
super(att) || translated?(att)
end
Not sure if it's the best solution, though..
This is a request to add support for globalize
v5+.
It looks like the globalize
gem is now at v5+, but there is a restriction in the gemspec in globalize-versioning
that limits it to globalize
< v5. The following fork has made changes that allow globalize
v5+ to be used with globalize-versioning
:
When I change a translated column of my model, 2 versions are created, one for the base model and one for the translation model. That seems right. But then both of these versions have the change in the change column. Why is that? That would mean we wouldn't actually need to create a version for the changed translation model, right. The version of the base model with the correct locale would be sufficient.
Can papertrail 13 or 14 be marked compatible?
As stated in #12 support is there but we need a new release in rubygems to use this.
Any chance we'll see Rails 7 supported soon?
Hi there,
May I know if the gem is compatible with paper_trail (4.0.0.beta1)? I wanted to update the paper_trail gem to get rid of deprecation warning in Rails 4.2 but encountered the following error. Thanks very much for your attention.
Bundler could not find compatible versions for gem "paper_trail":
In Gemfile:
globalize-versioning (> 0.1.0) ruby depends on> 3.0.0) ruby
paper_trail (
paper_trail (4.0.0.beta1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.