Last active
December 18, 2015 03:59
-
-
Save kernow/5721604 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
config.middleware.insert_after Warden::Manager, Dragonfly::Middleware, :reports | |
config.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :images |
This file contains hidden or 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
# File uploads | |
file_app = Dragonfly[:reports] | |
file_app.configure_with(:rails) | |
file_app.define_macro(ActiveRecord::Base, :file_accessor) | |
file_app.configure do |config| | |
config.server.before_serve do |job, env| | |
Rails.logger.info "************** in file before_serve" | |
unless env['warden'] && env['warden'].user && env['warden'].user.has_admin_role? | |
# Prevent direct access to file urls | |
throw :halt, [404, { 'Content-type' => 'text/plain' }, ['The content you are trying to access does not exist']] | |
end | |
end | |
end | |
# require 'dragonfly/rails/images' | |
# Regular image uploads | |
image_app = Dragonfly[:images] | |
image_app.configure_with(:rails) | |
image_app.configure_with(:imagemagick) | |
image_app.define_macro(ActiveRecord::Base, :image_accessor) | |
image_app.configure do |config| | |
config.server.before_serve do |job, env| | |
Rails.logger.info "************** in image before_serve" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment