---
title: This week in open source
teaser:
tags: news,open source
author: Mike Burns
published_on: 2011-12-16
---

## paperclip

Much of the work over the past week was done in [paperclip](https://github.com/thoughtbot/paperclip), so now you can upload files to your Rails apps with more flare and style!

It now supports an option for keeping old files, so you can pass `:keep_old_files` to `has_attached_file` and, when you destroy an attachment (`@user.avatar.destroy`) it won't actually delete the underlying files ([345ec74](http://github.com/thoughtbot/paperclip/commit/345ec743fc512f290e90451a7776d824f7e3b566 "Add ")). Many people find this useful for S3 storage, which hints that there may be a deeper problem elsewhere. This is thanks to Eike Bernhardt ([teefax](http://github.com/teefax)) but was originally

Christoph Lupprich ([kitto](http://github.com/kitto)) saw a quick way to speed up the `#public_url` method for Fog storage using AWS as the provider, so he did ([989ec0e](http://github.com/thoughtbot/paperclip/commit/989ec0eeaf5c94285a9ee89264c70af4f1ca17b2 "Fix Fog")).

I've long wanted a migration helper, and Daniel Schierbeck ([dasch](http://github.com/dasch)) wrote it with some git cleanup from Alexey Mahotkin ([693b528](http://github.com/thoughtbot/paperclip/commit/693b5280c0679751ad12d8e862b509750c981e9d "Add a test for #drop_attached_file"), [b922111](http://github.com/thoughtbot/paperclip/commit/b922111b25058b419c98ce53502ee41dbf5a8474 "Remove an unused require statement"), [f82c0d9](http://github.com/thoughtbot/paperclip/commit/f82c0d94f1fad37575b33ba67998ea7fa1f1fe41 "Further refactor the schema implementation"), [f3eacd2](http://github.com/thoughtbot/paperclip/commit/f3eacd2483ef9fdf2ac3c3a0758370c3ee7bed85 "Document Paperclip::Schema"), [e0a6732](http://github.com/thoughtbot/paperclip/commit/e0a6732409be0031c708579e2710d39c36495065 "Refactor the implementation of the schema helpers"), [ffbfc24](http://github.com/thoughtbot/paperclip/commit/ffbfc24e42aefc1cfb009697ad1311e00480ee8e "Add a proper test suite of the schema helper"), [)">500f1bb](http://github.com/thoughtbot/paperclip/commit/500f1bb11ecd10dd6ac01a0f8a7635ba4245015b "Add a helper that creates the Paperclip columns (three commits squashed into one by Alexey Mahotkin <squadette@gmail.com"), [b70ffbc](http://github.com/thoughtbot/paperclip/commit/b70ffbc9fc34e69a4b7086c1733e6421b6ead9a8 "Shorten migration roll-back also"), [65a6ae8](http://github.com/thoughtbot/paperclip/commit/65a6ae8c19e10cd3886a6696e6cf7739fa2bac82 "Fix the build on 1.9.2: require ./test/helper instead of just test/helper.")).

It looks like this:

    class AddAvatarColumnsToUser < ActiveRecord::Migration
      def self.up
        change_table :users do |t|
          t.has_attached_file :avatar
        end
      end

      def self.down
        drop_attached_file :users, :avatar
      end
    end

There were also some important internal changes. For example, Prem Sichanugrist ([sikachu](http://github.com/sikachu)) replaced the AWS::S3 gem with AWS::SDK ([1df1b03](http://github.com/thoughtbot/paperclip/commit/1df1b030c93ae6b452b0eec51781b8a29a7867e8 "Make sure that `aws-sdk` is installed by checking for AWS::Core instead"), [81129ad](http://github.com/thoughtbot/paperclip/commit/81129ad11c932897c2003144e8a2c76a5c613878 "Do not calling `AWS.stub!` right away, it"), [88a8af9](http://github.com/thoughtbot/paperclip/commit/88a8af955db647375411173c566a26ececc7118b "Change ENV["), [75f413d](http://github.com/thoughtbot/paperclip/commit/75f413da0f346be3f4b08199c3b7966d2bd5442d "Use AWS::SDK instead of AWS::S3 The original commit came from @amazonwebservices and @trevorrowe in #579. I had to revise the commit and make sure all the test cases are passing. All credits still goes to those guys, thanks a lot!"), [2cf7378](http://github.com/thoughtbot/paperclip/commit/2cf73787912d4eebfbdb5b9abfb386a80f534ce8 "Remove duplicate test from the merge")). He called out AWS ([amazonwebservices](https://github.com/amazonwebservices)) and Trevor Rowe ([trevorrowe](https://github.com/trevorrowe)) for helping, and John Joseph Bachir ([jjb](http://github.com/jjb)) updated the docs appropriately ([308f1a0](http://github.com/thoughtbot/paperclip/commit/308f1a0f0cd6be6b4190db2f2a71018eba13a2c4 "documentation for including aws-sdk in Gemfile")).

Prem also got Paperclip passing on Rubinius ([001fd99](http://github.com/thoughtbot/paperclip/commit/001fd99feff71509bd3227ac64ba3ca443dc931d "Remove Rubinius cache files for real this time.")).

In bug fixes, base URLs with a `?` but no `=` will produce Paperclip URLs using `?` ([128d664](http://github.com/thoughtbot/paperclip/commit/128d664c1143d119922393fde342431c1523535e "URLGenerator should disregard a ? which isn") and [bb22be3](http://github.com/thoughtbot/paperclip/commit/bb22be301a783b2e2ab58f7904231ffd8211766c "Use Net::HTTP instead of curl

There was some problem with command line parsing with a special character.")). Prem thinks that's the right behavior now, but it's tricky to nail down.

Nick Padgett ([npadgett](http://github.com/npadgett)) found an edgecase where we were calling `strip` on a non-string object, sometimes, and fixed that ([34913f1](http://github.com/thoughtbot/paperclip/commit/34913f12894b53031456c5cbbcb7117a8d912bbc "Standardize strip with resy of application.  Without to_s, causes errors like &quot;undefined method `strip")).

Dimitrij Denissenko ([dim](http://github.com/dim)) handled the case where using the `:id_partition` pattern in a URL or path pattern raises a `NoMethodError` on an unsaved resource ([ac82244](http://github.com/thoughtbot/paperclip/commit/ac822448489df3aa97ce896f3023d874ab36f12c "Fixed ID partitioning interpolation, when cloning attachments")). He and I are now enemies for life for his use of `nil`.

Prem fixed another bug: if you have a path or URL pattern with `:class` in it it will show a warning. He removed this warning ([b4ff2c5](http://github.com/thoughtbot/paperclip/commit/b4ff2c5777df6ac3b0942dc645cfde2d1ace62c8 "Do not show warning if :class exists in the interpolation URL

This fixes #660")).

Prem worked with Steve Richert ([laserlemon](http://github.com/laserlemon)) to show the Gemnasium results in the README ([3e20907](http://github.com/thoughtbot/paperclip/commit/3e209072794363df84a17c4ec6133221e8be9f8f "Add dependency status to the README via Gemnasium") and [777ac90](http://github.com/thoughtbot/paperclip/commit/777ac90092cc2ad7f71ea4b3633ac0372df22f35 "Update Cucumber dependency

This is necessary so Gemnesium will be green.")), and Prem also updated the README to be more readable ([adcd03c](http://github.com/thoughtbot/paperclip/commit/adcd03c93efc140c44433b3fe4a6d563a251061d "First pass on editing the README for more readability.")).

## fake_braintree

The fake credit card processor, [fake_braintree](https://github.com/thoughtbot/fake_braintree), hit 0.0.6 ([eed875e](http://github.com/thoughtbot/fake_braintree/commit/eed875ecdedef2609a91ae47fe6688eac963f178 "Bump to 0.0.6") and [0934f1e](http://github.com/thoughtbot/fake_braintree/commit/0934f1e6a74c058ca277ad271e3861a4ea298965 "Update the Changelog even more.")) this week as Ben Orenstein ([r00k](http://github.com/r00k)) added support for discounted subscriptions ([757c0aa](http://github.com/thoughtbot/fake_braintree/commit/757c0aad2998cab4475552410c60b949fc1bcf92 "Add basic support for adding discounts to subscriptions.")) and Gabe Berke-Williams ([gabebw](http://github.com/gabebw)) exposed the transactions that have run ([8dde09c](http://github.com/thoughtbot/fake_braintree/commit/8dde09c6a78ec4cab020ae9b095d454d4643d217 "Ensure that FakeBraintree.transactions is exposed.") and [ab93137](http://github.com/thoughtbot/fake_braintree/commit/ab93137eb58e736b24cb96c94cec1e44dd084403 "Use mattr_accessor.")).

## suspenders

Taking a stance on whether we play along with the little Open Directory Project game, [suspenders](https://github.com/thoughtbot/suspenders) now defaults to `NOODP` on every page which, as Matt Jankowski ([mjankowski](http://github.com/mjankowski)) points out, tells Web crawlers to never bother looking for ODP details ([6275d0f](http://github.com/thoughtbot/suspenders/commit/6275d0f280145394e15732694da547adf72b7ca6 "Google will prefer ODP listings over the site meta description unless this is in place")).

## shoulda-matchers

The sweet [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers) collection of RSpec matchers now has more accurate error messages for the `allow_value` matcher ([25c2623](http://github.com/thoughtbot/shoulda-matchers/commit/25c2623bb9d96cf6a446ecc141fdfefe5c4860fa "Merge branch ")), thanks to Clemens Helm ([clemenshelm](https://github.com/clemenshelm)). It uses the underlying internationalization information to generate this.

## bourbon

Another documentation update on [bourbon](https://github.com/thoughtbot/bourbon) as Phil LaPier ([plapier](http://github.com/plapier)) explained that multiple background images with shorthand notation are unsupported ([798aa1c](http://github.com/thoughtbot/bourbon/commit/798aa1ce860e7f2c2741c4ac2bf0b402ac226ff1 "Added unsupported background-image mixin to docs")), after clarifying that multiple background images themselves have fancy comma-separated syntax ([aa66831](http://github.com/thoughtbot/bourbon/commit/aa6683149d6538d883dd0b16fc02794300572917 "Added a note about shorthand notation for background-image")).
