even better integration

This commit is contained in:
John Bintz 2012-10-11 09:51:04 -04:00
parent 1ad4694503
commit ba98341916
2 changed files with 20 additions and 6 deletions

View File

@ -1,4 +0,0 @@
CarrierWave::Mongoid::Media.routes.draw do
get 'media/*path' => 'media#show'
end

View File

@ -1,9 +1,27 @@
require 'carrierwave'
module CarrierWave module CarrierWave
module Mongoid module Mongoid
class Media < ::Rails::Engine class Media < ::Rails::Engine
initializer 'carrierwave_mongoid_media.carrierwave' do DEFAULT_PREFIX = :media
class << self
attr_writer :prefix
end
def self.prefix
@prefix ||= DEFAULT_PREFIX
end
def self.routes(router, prefix = :media)
self.prefix = prefix
CarrierWave.configure do |c| CarrierWave.configure do |c|
c.grid_fs_access_url = '/media' c.grid_fs_access_url = "/#{prefix}"
end
router.instance_exec do
get "#{prefix}/*path" => "media#show", :as => :media
end end
end end
end end