Created
October 17, 2019 13:35
-
-
Save eftikharEmad/74b3b481b09315a9e8195d669e61ba25 to your computer and use it in GitHub Desktop.
after_create only see the last added record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Endpoint < ApplicationRecord | |
| #:user_id,:user_type, :devise_id, :signed_in | |
| belongs_to :user | |
| after_create :set_as_signed_in | |
| def set_as_signed_in | |
| device_endpoints = Endpoint.where(device_id: device_id) | |
| device_endpoints.update_all(signed_in: false) if device_sns_endpoints.count > 1 | |
| update_column(:signed_in, true) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment