Save 37% off PRO during our Black Friday Sale! »

CarrierWave: Rails Essential Gems

CarrierWave: Rails Essential Gems

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

3b5cb0411cbd1012acab1b60f7ce3606?s=128

Jesse Wolgamott

December 11, 2012
Tweet

Transcript

  1. CARRIERWAVE Rails Essential Gems: by @jwo for @houstonrb Tuesday, December

    11, 12
  2. 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
  3. It’s Sorta Like: acts_as_attachment attachment_fu paperclip Tuesday, December 11, 12

  4. Usage generate an Uploader Mount the uploader in a model

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

    uploaders in isolation Tuesday, December 11, 12
  6. 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
  7. 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
  8. Demo Time [imagine the best demo ever] Tuesday, December 11,

    12
  9. The Photo Tuesday, December 11, 12

  10. Pad vs Fill Tuesday, December 11, 12