I have a Rails 3 scope that excludes an array of ids.
What is the best way to write the scope so that it does nothing when the array is empty and is still chainable? I c
Here's a slight variation on Douglas' answer, using ruby 1.9 stabby lambda syntax and without the brackets in the where method.
scope :excluding_ids, ->(ids) {where("id NOT IN (?)", ids) if ids.any?}