-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Callbacks explicitely instead of using has_papertrail #607
Conversation
Wow, this is great! I haven't reviewed your implementation yet, but I think this is a great idea, giving users more control over their ActiveRecord callbacks. Specifically, being able to control the order in which callbacks happen will solve a whole class of issues, especially integration with other libraries that have their own callbacks. As you mentioned, this has been discussed before:
Precedent in other librariesOther popular ruby libraries give users control over callbacks, so there is a precedent for this. For example Other libraries go so far as to only provide methods, and require users to set up callbacks manually. For example Next steps for this PRThis is a big change, so it's going to take Ben and I a while to review. In the meantime, a few housekeeping requests:
|
Oh, I didn't think this would strike you as a big change, so I was a little sloppy about some things... For example I moved the InstanceMethod module to its own file, because I felt pretty bugged by that huge has_paper_trail.rb file. I should have moved that into another PR now that I think about it. But really don't expect too much of this, I just rewrote the has_paper_trail method to use the paper_trail_update(etc) methods etc and added an option to the destroy method... The other methods have been moved, but not changed, but it would not be hard to implement the option for them too. Could you give me some kind of guideline how to change the changelog? I didn't change it because I was under the impression that's what you guys want to do. |
Yeah, if you could split that refactoring into a second PR, that would really help use review this one more quickly. Thanks! |
Just follow the conventions you see in there. Further reading: http://keepachangelog.com/ |
ok... I have no idea how to do that. Should I just revert those changes, make another branche and make another PR? Or can I use some git magic? I really don't know... |
No idea how to do what? Split the refactoring into a second PR? |
ok, give me another day :) I have been sick for a few days, but I think I will be able to tackle this tomorrow. |
Docs: Contributing guide, initial revision [ci skip] fixed typo in readme
ok, I've squashed the commits, I am not really sure if it's worth it to revert the 'moved instance methods to its own file' commit and move it to another PR now that I've thought about it tbh, but of course I'll still do it if you prefer. |
Please do, thanks. We have very limited time to review PRs/issues, and the smaller this PR is, the easier it will be for us to review. Thanks. |
Control the order of `set_paper_trail_whodunnit` callback
.. to reflect that master now represents 5.0 [ci skip]
We would prefer to only constrain mysql2 to '~> 0.3', but a rails bug (rails/rails#21544) requires us to constrain to '~> 0.3.20' for now.
See previous commit.
Please remove any unnecessary refactoring, rebase on master, and squash everything into a single commit. After you've done that, we'll be able to review this PR. Thanks! |
Docs: Contributing guide, initial revision [ci skip] fixed typo in readme
[ci skip] Control order of `set_paper_trail_whodunnit` callback Fixes #301 Stop automatically adding the `set_paper_trail_whodunnit` before_filter. This gives people control over the order of this callback. Docs: Update compat. table .. to reflect that master now represents 5.0 [ci skip] Temporarily constrain mysql2 gem to ~> 0.3.20 We would prefer to only constrain mysql2 to '~> 0.3', but a rails bug (rails/rails#21544) requires us to constrain to '~> 0.3.20' for now. Also constrain mysql2 in the rails 3.0 gemfile See previous commit. updated readme to include added callbacks add explicit callbacks added rspec tests for callbacks added explicit callbacks moved instance methods to its own file added a setup_model function Docs: Contributing guide, initial revision [ci skip] fixed typo in readme removed redundant include update changeleog added callback-methods add explicit callbacks added rspec tests for callbacks added explicit callbacks moved instance methods to its own file added a setup_model function Docs: Contributing guide, initial revision [ci skip] fixed typo in readme removed redundant include update changeleog added callback-methods revoked unnecessary refactoring
Fabian, we can close this PR, right? It is superseded by #614 |
Refering to this 3rd-party issue I wrote some methods to set callbacks:
paper_trail_destroy(:after/:before) can be aliased as paper_trail_after_destroy/paper_trail_before_destroy.
There is a caveat when passing options:
will NOT result in paper_trail ignoring changes to :things and :other_things, but only :things, since the "initialization" will only be triggered once.
Also when using has_paper_trail will override the explicitely set callbacks:
will result in all events to be tracked and the ignore option will not be set at all...
Not sure how to fix those issues yet, because I did not want to get rid of has_paper_trail and/or break working functions...