Posted almost 8 years ago. Visible to the public.
Returning an empty ActiveRecord scope
Returning an empty scope can come in handy, e.g. as a default object. In Rails 4 you can achieve this by calling
none
Archive
on your ActiveRecord model.
CopyMyModel.none # returns an empty ActiveRecord::Relation object
For older Rails versions you can use the attached initializer to get a none
scope.
Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).