carrierwave-mongoid-media/app/controllers/media_controller.rb

13 lines
309 B
Ruby
Raw Normal View History

2012-10-11 00:45:35 +00:00
class MediaController < ApplicationController
def show
path = params[:path] + '.' + params[:format]
obj = Mongoid::GridFS[path]
raise Mongoid::Errors::DocumentNotFound.new(Mongoid::GridFS, :path => path) if !obj
self.content_type = obj.content_type
self.response_body = obj
end
end