rails_admin_history_rollback icon indicating copy to clipboard operation
rails_admin_history_rollback copied to clipboard

paper_trail restore relations

Open nicolasfranck opened this issue 10 years ago • 3 comments
trafficstars

Thanks for this great module!

The newest paper_trail makes it possible to restore relations (has_one and has_many), but you need to supply the options ":has_many => true, :has_one => true" to the method "reify" to make this possible:

https://github.com/airblade/paper_trail#associations

This to ensure backward compatibility, and not to confuse/enrage simple users.

Would it be interesting to add an extra button to restore also these associations? For example "rollback (including assocations)"

nicolasfranck avatar Aug 06 '15 13:08 nicolasfranck

Hi @nicolasfranck thanks for your feedback, really appreciated. Your idea sounds great, do you have a set up you'd be able to test this on? It would be awesome if you could help contribute this new feature to the module. Fancy submitting a pull request?

Cheers,

Rikki

rikkipitt avatar Aug 07 '15 11:08 rikkipitt

I'm working on it. But it's more complicating than you think.

When you only remove/add a relation, and change nothing to the parent record, there is no new version of this parent record. So no new version appears in history index, you can use as a reference. It works if you update both parent record and relations.

I'll notify you

nicolasfranck avatar Aug 07 '15 15:08 nicolasfranck

Hey @nicolasfranck, it's tricky indeed. When I get a spare moment, I'll take a look into it too. I'm sure between us we can figure it out. I'll create a branch for it soon so we can test it all works.

Rikki

rikkipitt avatar Aug 16 '15 15:08 rikkipitt