Welcome to Giant Robots Smashing Into Other Giant Robots — a weblog about development, business, design and technology — written by thoughtbot.

A Convenient Squirrel Addition

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.

1
2
3
4
5
6
7
8

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 at https://svn.thoughtbot.com/plugins/squirrel


About this entry

 

thoughtbot is hiring

We are hiring web developers and web designers in both Boston and New York, NY.

What are we up to?

We built Shoulda, an eclectic set of additions to Test::Unit; Paperclip to manage uploaded files without hassle; Jester, a REST/ActiveResource client library written in Javascript, and Squirrel, an enhancement for ActiveRecord's find syntax; — amongst some other projects.


Chad (President) and Jon (CTO) co-authored a technical book titled Pro Active Record: Databases with Ruby and Rails, which explores the ins and outs of the ActiveRecord ruby library. You can buy it today at Amazon.com.

About thoughtbot, inc.

We are a small web application development consulting business, with offices in Boston, MA and New York, NY. If you're looking to find a team for your next web development project or your new web application — get in touch.