No commit activity in last 3 years
No release in over 3 years
Exposing ActiveRecord::Relations from your controllers to views is bad for business. As much as it is convenient to do so, does it really make sense that your view can use an `unscoped` version of it? More importantly, testing what is and isn't in scope of a `ActiveRecord::Relation` is REALLY hard.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Build Status

RecordCollections

Don't expose ActiveRecord::Relations, expose RecordCollections!

Testing what is or isn't in scope of a ActiveRecord::Relation is REALLY hard. RecordCollections make it easy (so long as you use decently sized scopes).

Usage

Controllers

def index
  @users = RecordCollection.new(User)
      .limit_by(User.active)
      .and(User.first_name("Jane"))
      .and(User.over_21)
end

RSpec

subject(:users) { assigns[:users] }

it { should be_limited_by?(User.active) }
it { should be_limited_by?(User.first_name("Jane")) } # Yes, it even works with arguments to the scope
it { should be_limited_by?(User.over_21) }

it { should_not be_limited_by?(User.under_50) } # Maybe there are some scopes you definitely don't want