Permalink
Browse files

Update dragonfly

  • Loading branch information...
1 parent 4d5fa97 commit ba5e20fb0fa45146a2ab5d9e1da5c293a186035e @mshibuya mshibuya committed Feb 5, 2014
View
@@ -50,7 +50,7 @@ group :test do
gem 'coveralls', require: false
gem 'database_cleaner', '>= 1.2'
gem 'devise', '>= 3.2'
- gem 'dragonfly', '~> 0.9.0'
+ gem 'dragonfly', '~> 1.0'
gem 'factory_girl', '>= 4.2'
gem 'generator_spec', '>= 0.8'
gem 'launchy', '>= 2.2'
View
@@ -39,7 +39,7 @@ end
gem 'carrierwave', '>= 0.8'
gem 'devise', '>= 3.2'
-gem 'dragonfly', '~> 0.9.0'
+gem 'dragonfly', '~> 1.0'
gem 'mini_magick', '>= 3.4'
gem 'mlb', '>= 0.7'
gem 'paperclip', '3.5.2'
@@ -9,6 +9,6 @@ class FieldTest < ActiveRecord::Base
attr_accessor :delete_paperclip_asset
before_validation { self.paperclip_asset = nil if delete_paperclip_asset == '1' }
- image_accessor :dragonfly_asset
+ dragonfly_accessor :dragonfly_asset
mount_uploader :carrierwave_asset, CarrierwaveUploader
end
@@ -2,6 +2,7 @@ class FieldTest
include Mongoid::Document
include Mongoid::Paperclip
include ActiveModel::ForbiddenAttributesProtection
+ extend Dragonfly::Model
field :name, type: String
field :title, type: String
@@ -47,7 +48,7 @@ class FieldTest
field :dragonfly_asset_name
field :dragonfly_asset_uid
- image_accessor :dragonfly_asset
+ dragonfly_accessor :dragonfly_asset
mount_uploader :carrierwave_asset, CarrierwaveUploader
validates :short_text, length: {maximum: 255}
@@ -1,11 +1,27 @@
-if defined?(Mongoid::Document)
- require 'dragonfly'
+require 'dragonfly'
- app = Dragonfly[:images]
+# Configure
+Dragonfly.app.configure do
+ plugin :imagemagick
- # Configure to use ImageMagick, Rails defaults
- app.configure_with(:imagemagick)
+ protect_from_dos_attacks true
+ secret "904547b2be647f0e11a76933b3220d6bd2fb83f380ac760125e4daa3b9504b4e"
- # Allow all mongoid models to use the macro 'image_accessor'
- app.define_macro_on_include(Mongoid::Document, :image_accessor)
+ url_format "/media/:job/:name"
+
+ datastore :file,
+ root_path: Rails.root.join('public/system/dragonfly', Rails.env),
+ server_root: Rails.root.join('public')
+end
+
+# Logger
+Dragonfly.logger = Rails.logger
+
+# Mount as middleware
+Rails.application.middleware.use Dragonfly::Middleware
+
+# Add model functionality
+if defined?(ActiveRecord::Base)
+ ActiveRecord::Base.extend Dragonfly::Model
+ ActiveRecord::Base.extend Dragonfly::Model::Validations
end
@@ -1,5 +1,3 @@
-require 'dragonfly/rails/images'
-
RailsAdmin.config do |c|
c.model Team do
include_all_fields

0 comments on commit ba5e20f

Please sign in to comment.