mobility
mobility copied to clipboard
Add support for versioning with paper_trail
Context
At the moment, it's not possible to use paper_trail with mobility. We're using mobility with a table backend and paper_trail cannot save the changes. It should be considered to add support to versioning gems such as paper_trail. We switched from globalize to mobility because of performance issues. But as globalize is already supporting this feature, I hope versioning support can be added to mobility as well (https://github.com/globalize/globalize-versioning)
Expected Behavior
Changes in models using mobility are saved in paper_trail as well.
Actual Behavior
Changes in models using mobility are not saved in paper_trail db.
Possible Fix
See https://github.com/globalize/globalize-versioning for a possible solution.
Hi @jokrah, thanks for the suggestion. I contributed to globalize-versioning so I know the gem (it's actually very small).
I agree this would be a nice addition, unfortunately the priority for me right now is #323 and also on cleaning up and releasing a v1.0, so I don't think I will get to this anytime soon.
If you or anyone else wants to give it a try, I'm happy to provide help on it. The challenge with Mobility is always that ideally you want to support all backends, not just one backend. I managed to do that with both friendly_id-mobility and mobility-ransack so those may provide another reference point.
I know it's not related to this issue, but just out of curiosity:
We switched from globalize to mobility because of performance issues.
What performance issues were those?
I'm also very interested in compatibility for PaperTrail. I currently use Globalize and can't really switch unless this is supported. This library looks great though, so keep up the good work!
Thanks @sedubois I will eventually look into it. Rails 6.0 compatibility is done but I'm working on a rewrite for an eventual v1.0 so that's still priority at the moment.
@shioyama I just watched your RailsConf talk from last year (better late than never), was very interesting. This reminded me of this library. Are you still planning to bring PaperTrail support or develop other features or is the development on hold? Keep up the good work 😊
Thanks @sedubois! Glad you enjoyed the RailsConf talk.
About PaperTrail support, I think you can safely assume I will not get to working on it anytime soon (if ever). I want to support Mobility with limited time, so I need to keep the core simple, and the more integrations there are the hard it will be to support everything.
Hope that makes sense :slightly_smiling_face:
Thanks @shioyama I understand. Would you be aware of other methods (outside of core) to achieve this?
I'm actually not familiar enough with paper trail to really say, but the Globalize versioning gem is I believe quite minimal so it shouldn't be so hard.
There is a kind of API for extending Mobility, used by mobility-ransack for example, but it's not documented. Making it clearer how to extend Mobility is something that I would be open to doing (and actually want to do).
Actually the API for extending Mobility is one of the things that should be clearer with the release of v1.0. The master branch has a lot of changes that should make this more straightforward. But again, not documented other than in specs.
I've created an issue in #366 to update inline docs on the changes in master to make it easier to develop extensions for Mobility v1.0.
This is unfortunately not going to happen, so I'm closing this.