Skip to content

Instantly share code, notes, and snippets.

@chrisarcand
Created December 7, 2021 14:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
class ApplicationRecord
def in_scope?(sym)
self.class.public_send(sym).exists?(id)
end
end
class Location < ApplicationRecord
scope :editable -> {...}
# OR
def in_editable?
self.class.editable.exists?(id)
end
end
# loc = Location.last
#
# loc.in_scope?(:editable)
# loc.in_editable?
# Location.editable.exists?(loc.id) # FWIW though I'd just use this, without any of this extra stuff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment