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

Crashes when reverting a model linked to not existing child model #15

Closed
serge1peshcoff opened this issue Aug 5, 2016 · 2 comments
Closed

Comments

@serge1peshcoff
Copy link
Contributor

serge1peshcoff commented Aug 5, 2016

Related: paper-trail-gem/paper_trail#841

How to reproduce:

  1. I have Stadium and StadiumUser models, and the dependency between them is like that:
class StadiumUser < User
    ....
    has_one :stadium, foreign_key: "user_id", dependent: :destroy, required: true
    after_create :make_stadium
end
  1. I created the StadiumUser (Stadium is created with it)
  2. I deleted StadiumUser via rails_admin
  3. I find the Stadium deletion entry and press "Restore"
  4. this error appears
PG::ForeignKeyViolation at /stadium/history
ERROR:  insert or update on table "stadiums" violates foreign key constraint "fk_rails_b1bd5d1cc5"
DETAIL:  Key (user_id)=(56) is not present in table "users". 
@rikkipitt
Copy link
Member

Hi @serge1peshcoff does this help?

https://github.com/airblade/paper_trail#4b-associations

Related issue on this repo: #5

Rikki

@serge1peshcoff
Copy link
Contributor Author

I can't check it for now, but it shouldn't work either, since no has_one: true param is specified when using paper_trail's reify.
Anyway, will check it out later.

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