The versatility of the `exists?` method
My normal use of the exists?
method in ActiveRecord has always been to toss it on the end of a query of some kind:
Animal.where(name: "dragon").exists?
# => false
However, I discovered that the method can be called directly on a class and passed options:
Animal.exists?(name: "dragon")
Animal.exists?(123)
Animal.exists?(id: [123, 345])
Check out the full documentation for more examples
Tweet