A Convenient Squirrel Addition

Jon Yurek

This is probably something that should have been done sooner, but I didn’t get around to it and it wasn’t immediately important to us. Since it now is, I changed Squirrel’s call to ActiveRecord::Base#find to include all parameters passed in, even the extra hash variables find normally uses. While this isn’t terribly amazing on its own (although it does mean you can use :limit even though it doesn’t have Squirrel-specific syntax yet), it allows the usage of the terribly lovely paginating_find plugin.

posts = Post.find(:all, :limit => 10) do
    created_on > 7.days.ago
end

orders = Order.find(:all, :page => { :size => 5, :current => 2 } ) do
    customer.id == params[:customer_id]
end

Both of these will work as expected now. Well, the second one needs paginating_find installed, but you know what I mean.

As always, the repo is on github.

About thoughtbot

We've been helping engineering teams deliver exceptional products for over 20 years. Our designers, developers, and product managers work closely with teams to solve your toughest software challenges through collaborative design and development. Learn more about us.