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

How does association versioning work with belongs_to? #503

Closed
marnen opened this issue Mar 20, 2015 · 9 comments
Closed

How does association versioning work with belongs_to? #503

marnen opened this issue Mar 20, 2015 · 9 comments

Comments

@marnen
Copy link
Contributor

marnen commented Mar 20, 2015

I have a use case where I have the following:

class Project < ActiveRecord::Base
  has_paper_trail
  belongs_to :client
end
class Client < ActiveRecord::Base
  has_paper_trail
  has_many :projects
end

I'd like to figure out how to do @project.versions.last.reify in such a way as to get the Client version along with the Project version. All the examples in the docs would have me do @client.versions.last.reify has_many: true and get a bunch of Project records, but that's not what I need: I just need one Project record, along with the Client version that was present when the Project version was saved. Is this possible (maybe @project.versions.last.reify has_one: true?), or do I just need to store the Client and Project version numbers separately?

@batter
Copy link
Collaborator

batter commented Mar 24, 2015

I believe this is a dup of #498.

Versioning of associations is incredibly complex, which is part of the reason why it took so long to even fathom working on this feature in the first place. As the documentation regarding associations states, this is not currently supported with the current source but if you have any ideas or suggestions then please give it a shot and open up a pull request.

@marnen
Copy link
Contributor Author

marnen commented Mar 25, 2015

I don't think this is a duplicate of #498, though it's certainly related.

And yes, association versioning is hard (well, my own use case is simple, but it doesn't generalize).

@jaredbeck
Copy link
Member

I noticed there hasn't been any activity on this in four months. Marnen, is this still something you'd like to contribute? Unless you're working on it, my preference would be to close the issue. Thanks!

@theRealNG
Copy link
Contributor

I have worked on this.
theRealNG@1257db3

Will need to refactor the code a bit and write test cases.
Will place a pull request once it is done, so please don't close this.

@jaredbeck
Copy link
Member

[I] will place a pull request ..

@theRealNG did this ever happen? I'd like to close this if no one is working on it.

@marnen
Copy link
Contributor Author

marnen commented Feb 24, 2016

@jaredbeck I haven't been actively working on the project for which I'm using paper_trail. But I confess I'm not sure why you'd close this: the issue still exists—even if no one is working on it, shouldn't it stay open so that people know it is still something that needs attention?

@theRealNG
Copy link
Contributor

Sorry forgot about this. Finished working on it. Will work on writing the specs tomorrow.

@theRealNG
Copy link
Contributor

@jared I think we can close this issue.

@jaredbeck
Copy link
Member

Closed by #730. Thanks NG. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants