config/initializers/dragonfly.rb in alchemy_cms-2.9.1 vs config/initializers/dragonfly.rb in alchemy_cms-3.0.0.rc5

- old
+ new

@@ -1,30 +1,27 @@ -require 'dragonfly' - # Alchemy CMS Dragonfly configuration. # Pictures -pictures = Dragonfly[:alchemy_pictures] -pictures.configure_with :imagemagick -pictures.configure_with :rails -pictures.define_macro ActiveRecord::Base, :image_accessor -pictures.configure do |config| - config.datastore.configure do |store| - store.root_path = Rails.root.join('uploads/pictures').to_s - store.store_meta = false - end - # You only need this if you use Dragonfly url helpers, what you not need to ;) - # If you use the Dragonfly url helpers and you have a different mountpoint for Alchemy, - # you have to alter this to include the mountpoint. - config.url_format = '/pictures/:job/:basename.:format' +Dragonfly.app(:alchemy_pictures).configure do + plugin :imagemagick + datastore :file, + root_path: Rails.root.join('uploads/pictures').to_s, + store_meta: false + url_format '/pictures/:job/:basename.:format' + url_path_prefix Alchemy::MountPoint.get end # Attachments -attachments = Dragonfly[:alchemy_attachments] -attachments.configure_with :rails -attachments.define_macro ActiveRecord::Base, :file_accessor -attachments.configure do |config| - config.datastore.configure do |store| - store.root_path = Rails.root.join('uploads/attachments').to_s - store.store_meta = false - end +Dragonfly.app(:alchemy_attachments).configure do + datastore :file, + root_path: Rails.root.join('uploads/attachments').to_s, + store_meta: false +end + +# Logger +Dragonfly.logger = Rails.logger + +# Add model functionality +if defined?(ActiveRecord::Base) + ActiveRecord::Base.extend Dragonfly::Model + ActiveRecord::Base.extend Dragonfly::Model::Validations end