Besi
Besi

Reputation: 22949

Dynamically adding paper_trail to translations in Rails5

I have an application that translates some model data and I would like to version this data. So this is my setup:

I have created a pull-request that should add rails 5 functionality to the globalize-versioning gem.

I already did this:

Now all tests in the projects fail and I can't quite figure out how to add the paper_trail functionality to the translations objects from globalize.

Upvotes: 1

Views: 247

Answers (1)

dfherr
dfherr

Reputation: 1642

You changed the alias_method_chain wrongly.

alias_method :versioning, :setup_translates!
alias_method :setup_translates!, :versioning

This only aliases versioning and setup_translates!. What alias_method_chain actually tries is to make sure a overriden method is still callable.

So this:

alias_method_chain :setup_translates!, :versioning

should be changed to:

alias_method :setup_translates_without_versioning!, :setup_translates!
alias_method :setup_translates!, :setup_translates_with_versioning!

Try if this solves the issues.

source: alias_method_chain

Upvotes: 2

Related Questions