Created
February 22, 2010 19:10
-
-
Save merbjedi/311364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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