Ruby Quicktips: How to check if objects or relations exist
Here’s an interesting fact when checking if objects or relations exist in a collection.
To check if there were any items present in a collection you can do something like this:Object.relation.present?This, however, is better:
Object.relation.any?Turns out that - when you request…
(Source: mariovisic, via rubyquicktips)