Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Standup 12/21/2009: Bundler and symbol.to_proc

Nathan Wilmes
Monday, December 21, 2009

Ask for Help

“How do I make attachment_fu use both the file system and S3 as storage backends?”

One of our clients would like to migrate attachments from the file system to S3. They want a clever way to make attachment_fu look in S3 or the filesystem, where new files are in S3 and old files are in the filesystem.

Their current solution, which they’re not super happy with, is to monkeypatch the S3 backend by extending it with file system methods. This solution doesn’t really seem to work too well, since the two backends share some of the same methods, and calling “extend FileSystemBackend” doesn’t give them the freedom to pick and choose their methods. In addition, their patch makes the S3 backend not be an S3 backend any more, which could cause problems for maintenance down the road.

A better solution is to define a new backend object, based on the S3 backend but falling back to file system-style methods. Attachment_fu supports defining custom backend modules; a class using :storage => :my_storage would look for a backend module called Technoweenie::AttachmentFu::Backends::MyStorageBackend.

Attachment_fu still has a design problem. The backend objects are all modules, not classes. As a result, it’s not easy to make a new backend descend from one of the existing backends.

Interesting Things

  • The new version of the bundler gem, version 0.7.2, does not seem to be Ruby 1.8.6 compliant. The gem relies on symbol.to_proc, which is part of Ruby 1.8.7 (and Rails). A native Ruby 1.8.6 without Rails does not support this method.

Issue tracking: http://github.com/wycats/bundler/issues/#issue/134

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

2 Comments

  1. Stephan Wehner says:

    Is it not easiest to upload all files in one go, and after that use the S3 backend exclusively?

    Can they not do that?

    Stephan

    December 21, 2009 at 1:21 pm

  2. AW says:

    I had that very same thought… upload existing assets to Amazon S3 in bulk.

    If you’ve got a system that can’t go down for the hour or so it’d take, modify production to save locally and to Amazon S3 simultaneously… then once the bulk upload is done, switch over to Amazon S3 exclusively, and bin the local filesystem uploads.

    December 21, 2009 at 2:34 pm

Add New Comment Cancel reply

Your email address will not be published.

Nathan Wilmes

Nathan Wilmes
San Francisco

Recent Posts

  • Performance tuning an old Pivotal app – how I did it
  • Standup 2/24/2001-2/25/2001
  • Standup 2/23/2011 – mocking AJAX for jQuery 1.5
Subscribe to Nathan's Feed

Author Topics

agile (14)
testing (3)
ruby on rails (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >