Created
December 7, 2021 14:10
-
-
Save chrisarcand/1227578c97415db585600228254813e8 to your computer and use it in GitHub Desktop.
This file contains 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 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