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

Overriding the created at date on version create #374

Closed
straydogstudio opened this issue May 30, 2014 · 8 comments
Closed

Overriding the created at date on version create #374

straydogstudio opened this issue May 30, 2014 · 8 comments
Milestone

Comments

@straydogstudio
Copy link
Contributor

Is there any way to override the created at date for a version? I am importing data from a legacy system and trying to recreate a change history in paper_trail.

Sorry if I missed this. I've searched and not found it.

I'll fork and give it a whirl if there is no way to do it.

@batter
Copy link
Collaborator

batter commented May 30, 2014

PaperTrail::Version instances inherit from ActiveRecord::Base so it is possible to override the created_at date, just like you can with any other model. Are you asking if you can do it while generating the versions or what?

@straydogstudio
Copy link
Contributor Author

I'm sure I could do it manually, creating individual Versions. Perhaps that is best.

I was just wondering if, when saving a versioned class, if the Version can adopt the created_at value.

@straydogstudio
Copy link
Contributor Author

I really meant using the update_at value of the versioned class for the Version created_at.

@batter
Copy link
Collaborator

batter commented May 30, 2014

As of now, versions get built using callbacks, after_create, before_update, etc. I am about to start working on a feature where the created_at value for the versions that get generated will be force overridden to use the exact timestamp that the updated_at value is for the base model, but it's not ready yet. See #354

If you want to take a crack at it, be my guest. You would need to switch the version generation for update events to be built using after_update callbacks in order to ensure the base model is persisted and that timestamp is available.

@straydogstudio
Copy link
Contributor Author

I'll take a look.

@straydogstudio
Copy link
Contributor Author

Submitted a pull request.

@straydogstudio
Copy link
Contributor Author

See #375

@batter
Copy link
Collaborator

batter commented Jul 30, 2014

CHANGELOG actually updated via 071282f

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

2 participants