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

A lot of same requests after new reader creating #79

Closed
ytrrty opened this issue Sep 14, 2016 · 5 comments
Closed

A lot of same requests after new reader creating #79

ytrrty opened this issue Sep 14, 2016 · 5 comments

Comments

@ytrrty
Copy link

ytrrty commented Sep 14, 2016

After creating reader (user), I getting a lot of same requests. It's creating and deleting read_mark about 18 times.

SQL (6.7ms) DELETE FROM "read_marks" WHERE "read_marks"."reader_id" = $1 AND "read_marks"."reader_type" = $2 AND "read_marks"."readable_type" = $3 [["reader_id", 50763], ["reader_type", "User"], ["readable_type", "Event"]]

SQL (11.9ms) INSERT INTO "read_marks" ("reader_id", "reader_type", "readable_type", "timestamp") VALUES ($1, $2, $3, $4) RETURNING "id" [["reader_id", 50763], ["reader_type", "User"], ["readable_type", "Event"], ["timestamp", "2016-09-14 13:12:51.715057"]]

2016-09-14 16 24 24

@ytrrty ytrrty changed the title A lot of same requests A lot of same requests after new reader creating Sep 14, 2016
@ledermann
Copy link
Owner

Hm, the two SQL queries (DELETE + INSERT) are from #setup_new_reader, which is executed as a callback for after_create.

Maybe there is a class loading issue in your app? It seems to me that the acts_as_reader class method is executed multiple times, so the callback fires multiple times.

@ytrrty
Copy link
Author

ytrrty commented Sep 14, 2016

No, acts_as_reader executed one time in one model.
When I restart the server method is called again one time, but over time the number of calls increases.

@ledermann
Copy link
Owner

Didn't see this before. Do you have any more background info about the issue? What Rails version? In production or in development env?

ledermann added a commit that referenced this issue Sep 15, 2016
Don’t care if `.acts_as_reader` or `.acts_as_readable` is called
multiple times.

Belongs to #79
@ledermann
Copy link
Owner

@ytrrty Please checkout my latest commit. Does this help?

@ledermann
Copy link
Owner

Should be fixed by 4b744fa

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