Skip to content

Instantly share code, notes, and snippets.

@merbjedi
Created February 22, 2010 19:10
Show Gist options
  • Save merbjedi/311364 to your computer and use it in GitHub Desktop.
Save merbjedi/311364 to your computer and use it in GitHub Desktop.
# Here's my CarrierWave Config
require 'carrierwave/orm/mongomapper'
CarrierWave.configure do |config|
config.storage = :grid_fs
config.grid_fs_access_url = "/attachments/show"
config.grid_fs_database = "files"
config.grid_fs_host = "localhost"
end
# Here's my uploader
class LogoUploader < CarrierWave::Uploader::Base
end
# Here's what I added to my MongoMapper Model
mount_uploader :logo, LogoUploader
# Here's my controller action:
# GET /attachments/logos/:id
def logo
@model = MyModel.find_by_id(params[:id])
@logo = @model.logo
send_data @logo.read, :type => @logo.file.content_type
end
# my model logo.url seems fairly useless. the same url shows up for every single one, so I cant use it in my controller action
@model.logo.url => "/attachments/show/uploads/logo.gif"
I have to use: "/attachments/logo/#{@model.id}" in my image href
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment