Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CarrierWave: Rails Essential Gems

CarrierWave: Rails Essential Gems

Part of an ongoing series at HoustonRB showing off @jwo's essential gems for Rails.

Jesse Wolgamott

December 11, 2012
Tweet

More Decks by Jesse Wolgamott

Other Decks in Technology

Transcript

  1. Uses for CarrierWave upload photo download photo from url upload

    file (pdf, word, whatever) process image thumbnails Store files locally, or in the Cloud Tuesday, December 11, 12
  2. Usage generate an Uploader Mount the uploader in a model

    Migrate a string "photo", "file", "image" to the model Profit Tuesday, December 11, 12
  3. Why an Uploader You can re-use uploaders You can test

    uploaders in isolation Tuesday, December 11, 12
  4. Installation Steps 1. Add to gemfile: `gem 'carrierwave'` 2. bundle

    that thing 3. `rails g profile name photo` 4. `rails g uploader image` 5. add to photo.rb: `mounts_uploader :photo, ImageUploader Tuesday, December 11, 12
  5. Hints 1. Always use Fog, even in development 2. Don't

    use Fog in test mode [really, don't even process attachments in test] 3. Know what resize_to_fill vs resize_and_page 4. Create your buckets ahead of time 5. For PDFs and files, add Tuesday, December 11, 12