Skip to content

Instantly share code, notes, and snippets.

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