winton / acts_as_archive

Don't delete your records, move them to a different table
MIT License
372 stars 87 forks source link

Restoring Associations #16

Closed adrianpike closed 13 years ago

adrianpike commented 13 years ago

Dependent associations that get archived aren't restored automatically.

winton commented 13 years ago

I've tested every kind of Rails associations in the specs. Must be missing something. Could you provide code examples of what isn't working?

adrianpike commented 13 years ago

Whala!

https://gist.github.com/787267

It might be the :quick, now that I've got mover patched to work with sqlite I'll try pulling that and see if it changes anything.

edit: Nope, removing :quick doesn't help. I'm on Rails 3.0.3, FWIW. edit2: aha! https://gist.github.com/787274

adrianpike commented 13 years ago

Got it - acts_as_archive was above my association definitions, so at the time that the subclass was defined, the inheritable_attribute for reflections was empty.

Probably worth mentioning it in a gotchas or in the readme. I'll try and think about any clever solution that can be done on a_a_a's end.

winton commented 13 years ago

Ah, yes, I had come across that as well but had totally forgotten. Thanks for the reminder, adding to readme.

cwade commented 13 years ago

I think I'm seeing this issue again now that the syntax has changed so that the acts_as_archive declaration isn't made explicitly. Any suggestions? (I tried explicitly adding the declaration, but my archive model still returns [] for reflect_on_all_associations).