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

ActiveRecord::AssociationTypeMismatch (Article(#69835604302140) expected, got Article(#69835603825080)) #281

Open
brxue opened this issue Aug 8, 2017 · 0 comments

Comments

@brxue
Copy link

brxue commented Aug 8, 2017

Hi,

My project has an Article model which behaves as ordered tree supported by closure_tree.

Recently when creating new models, it reports the following error, does anyone meet them before?

Started POST "/articles" for 127.0.0.1 at 2017-05-24 02:00:38 +0800
Processing by ArticlesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"ETX26zVwht+78Rb0XjCieOfMqipnWMQOi1sCcWXNqNg=", "article"=>{"title"=...
...
INSERT INTO "articles" ("body"...
...
SELECT pg_try_advisory_lock(1396095756,0) AS tc246088da827c93e07b309449ae083d5
SELECT pg_advisory_unlock(1396095756,0) AS tba8edd90f04ff74cfb4203ec7535c563
ROLLBACK
Completed 500 Internal Server Error in 39ms

ActiveRecord::AssociationTypeMismatch (Article(#69835604302140) expected, got Article(#69835603825080)):
  app/controllers/articles_controller.rb:152:in `block in create'
  app/controllers/articles_controller.rb:151:in `create'

This error looks like randomly occur. Currently I can't reproduce it locally, but does anyone meet it before?

Another question is why it tries to lock article_hierarchies when the parent_id is going to be set as nil? In a successful ArticleController#create, after LOCK is granted it tries to update articles.section_number which is tree order, but why? (it is a root node!). The sequence of LOCK/updateSectionNumber/UNLOCK will disappear if an "after_create" callback is registered to re-save with some other column updated, this also looks strange to me.

I'm using closure_tree 5.2.0, rails 4.2.7.

Any clue to debug?

Thanks in advance.
Brian

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

1 participant