Skip to content

Instantly share code, notes, and snippets.

@eftikharEmad
Created October 17, 2019 13:35
Show Gist options
  • Select an option

  • Save eftikharEmad/74b3b481b09315a9e8195d669e61ba25 to your computer and use it in GitHub Desktop.

Select an option

Save eftikharEmad/74b3b481b09315a9e8195d669e61ba25 to your computer and use it in GitHub Desktop.
after_create only see the last added record
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