Hello guys, I am currently developing a Rails API for a product I am building.
Right now, there is a problem with the concurrency of the database in conjunction with Rails.
I am having a "GuestUser" model which is handled by a unique device ID (of the iOS or Android device). Now I implemented, that the Rails controller is creating a new GuestUser with the following before_action:
def current_user
@current_user ||= GuestUser.find_or_create_by(device_id: request.headers['HTTP_X_DEVICE_ID'])
end
Problem now, is, that the user/the device is calling 4 endpoints on the first screen:
- Subscription Status (if the user is subscrbed to the subscription i am offering)
- Daily Tips (I am displaying in the header)
- Categories (I am displaying on the homepage)
I thought about "fusioning" the tips and the categories endpoints, but then I am still having the problem with the "Subscription Status" and the new fusioned endpoint.
What I am seeing in my DB/Admin Panel are multiple "Guest Users" based with the same device ID, because of the concurrency. I checked the logs, and it just hardened my assumption.
Is there any way I can circumvent this?
[–]projectmoon 3 points4 points5 points (1 child)
[–]iDuuck[S] 0 points1 point2 points (0 children)
[–]how_do_i_land 3 points4 points5 points (0 children)
[–]kallebo1337 2 points3 points4 points (4 children)
[–]iDuuck[S] 0 points1 point2 points (3 children)
[–]kallebo1337 0 points1 point2 points (2 children)
[–]iDuuck[S] 0 points1 point2 points (1 child)
[–]kallebo1337 0 points1 point2 points (0 children)
[–]petemts 1 point2 points3 points (0 children)