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
Pivotal Labs

SF Standup for Monday, 4/25/2011: What gem do you use for file upload?

Pivotal Labs
Tuesday, April 26, 2011

Help

What are projects using for file upload? Paperclip?
Carrierwave?

Most continue to use Paperclip, though a few projects have
successfully used Carrierwave. Carrierwave apparently has better mongo support.

I tried to setup ruby and rails, and installed the latest
mysql gem and I get warning messages about the mysql gem.

Others have experienced this too and offered to help. The main answer
seemed to be “the warnings are lies, it will work.”

Interesting

  • Checkout Pry. It’s an irb replacement that includes tab
    completion and cd and ls for navigating scopes.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Mike Grafton

Election Day Standup, 06/08/2010

Mike Grafton
Tuesday, June 8, 2010

Help

How do I migrate paperclip attachments from one model to another?

A Pivot wants to do his civic duty of embracing change. This means refactoring his domain model to suit the emerging requirements of his product team. Unfortunately, this also means he has to move a paperclip attachment from one model to another. Paperclip does not appear to have a built in way to do this.

The opinion of the group was to use the brute-force solution: write some code to do the migration yourself. If you are using Amazon S3 for storage (which this project is), you can do an S3 ‘cp’ command to move the assets from one path to another. At the end, you can use the rake command ‘paperclip:refresh:thumbnails’ to re-generate the thumbnails.

If you want to do this by hand, cyberduck has a nice interface for batch re-naming of files on S3.

Interesting

Amazon CloudFront now supports HTTPS

They also dropped their prices.

IE has a limit of 31 CSS files.

This has bitten many Pivots over the years. Your 32nd (and up) CSS file will be silently ignored.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Stubbing out Paperclip/ImageMagick in Tests

Pivotal Labs
Tuesday, May 18, 2010

Many people use the ultra popular Paperclip library to handle file attachments in Rails. Unfortunately the Paperclip documentation does not cover how to stub out calls to ImageMagick in your test suite. Without the proper stubs in place a test suite that uses Paperclip will take much, much longer to run.

In the grease your suite presentation by Nick Gauthier it has a slide titled Quickerclip that describes what needs to be done to spend up Paperclip in tests, basically you need to keep it from shelling out to ImageMagick. Alas, the presentation does include code for how to achieve Quickerclip.

As the presentation shows Paperclip.run is the method that needs to be changed. The first parameter passed to Paperclip.run is the ImageMagick command be executed. Paperclip uses the identify and convert commands. The identify command is used to determine the dimensions of an image. The convert command is the really heavy one that does image manipulation and thumbnail generation. Here is a redefinition of Paperclip.run with sensible behavior for tests.

module Paperclip
  def self.run cmd, params = "", expected_outcodes = 0
    case cmd
    when "identify"
      return "100x100"
    when "convert"
      return
    else
      super
    end
  end
end

class Paperclip::Attachment
  def post_process
  end
end

Redefining post_process in Paperclip::Attachment is an optional additional optimization. In Paperclip, post_process eventually calls Paperclip.run("convert") and by short-circuiting the method earlier in the chain we save a few cycles.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (780)
  • rails (113)
  • testing (88)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (55)
  • techtalk (44)
  • rspec (38)
  • ironblogger (32)
  • productivity (30)
  • activerecord (29)
  • gogaruco (29)
  • git (28)
  • nyc (27)
  • rubymine (26)
  • bloggerdome (23)
  • mobile (22)
  • process (21)
  • pivotal tracker (20)
  • cucumber (20)
  • jasmine (19)
  • design (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • css (13)
  • tdd (13)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to paperclip Feed
  • 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 >