Skip to content
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

Enable version associations through config property #2

Closed
wants to merge 549 commits into from

Conversation

TMaYaD
Copy link
Owner

@TMaYaD TMaYaD commented Mar 23, 2015

Apologies for developed-on-github pullrequest. Currently on vacation with poor internet.

owenr and others added 27 commits January 19, 2016 07:39
Default order by timestamp to ensure early versions are cleaned
Looks like the heading changed at some point, not allowing one to easily click down to that section
Fix link to Custom Serializer section
Remove duplicate link to RailsCast
When running rspec from rake, hide the list of specs.
(bit.ly/1nVq3Jn)
add documentation for paper_trail-globalid extentsion
Note that the `private` access modifier has been removed. Actually fixing
said modifier would be a breaking change.
jaredbeck and others added 29 commits May 15, 2016 03:23
Log errors when versions can't be created
It already was organized *in memory* but now it's organized in files.

Also, there are six fewer methods being mixed into the model class
(they became ObjectAttribute and ObjectChangesAttribute).

I like how the legacy (rails < 4.2) support is now all in one file,
so it'll be really easy to drop when the time comes.

Finally, a minor thing, I renamed CastedAttributeSerializer to
CastAttributeSerializer, because I don't think "casted" is the
correct conjugation.
Break AttributesSerialization into small modules
When updating 2 models with a HABTM association, and using
accepts_nested_attributes_for, the association was using the
version ID instead of the transaction ID to reference the change.
This was braking the association logic and preventing proper
reification.
Fix MySQL 5.6 bug re: item_type length
* Accept either a String or a Symbol
* Correctly warn on beta versions of ActiveRecord 5
…arning

Fix deprecation warning for paper_trail_on_destroy(:after)
Problem
-------

`has_paper_trail` adds too many methods to the ActiveRecord model.

> If I'm counting correctly, installing the paper_trail gem adds 36 instance
> methods and 10 class methods to all of your active record models. Of those
> 46, 13 have a prefix, either "pt_" or "paper_trail_". I don't know what the
> best way to deal with this is. Ideally, we'd add far fewer methods to
> people's models. If we were able to add fewer methods to models, then I
> wouldn't mind prefixing all of them.
> #703

Solution
--------

Add only two methods to the AR model.

1. An instance method `#paper_trail`
2. A class method `.paper_trail`

The instance method would return a `RecordTrail` and the class method would
return a `ClassTrail`. Those names are totally up for debate.

Advantages
----------

- Plain ruby, easy to understand
- Adding new methods to e.g. the `RecordTrail` does not add any methods to
  the AR model.
- Methods privacy is more strongly enforced.
- Enables isolated testing of e.g. `RecordTrail`; it can be constructed with a
  mock AR instance.

Disadvantages
-------------

- Two new classes, though they are simple.
…ontroller

Adding guard clause to prevent calling user_for_paper_trail
…_warning

Add filename to whodunnit warning
People still don't realize that the master readme documents
unreleased features.

e.g. #829

[ci skip]
@TMaYaD TMaYaD closed this Jun 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet