Commit e59d0b53 by Prem Sichanugrist

Move Schema includes into Paperclip::Glue

parent ec1aa8be
require 'paperclip/callbacks'
require 'paperclip/validators'
require 'paperclip/schema'
module Paperclip
module Glue
......@@ -8,6 +10,12 @@ module Paperclip
base.send :include, Validators
base.class_attribute :attachment_definitions
if defined?(ActiveRecord)
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema)
end
locale_path = Dir.glob(File.dirname(__FILE__) + "/locales/*.{rb,yml}")
I18n.load_path += locale_path unless I18n.load_path.include?(locale_path)
end
......
......@@ -3,27 +3,24 @@ require 'paperclip/schema'
module Paperclip
require 'rails'
class Railtie < Rails::Railtie
initializer 'paperclip.insert_into_active_record' do
ActiveSupport.on_load :active_record do
Paperclip::Railtie.insert
end
end
rake_tasks do
load "tasks/paperclip.rake"
end
rake_tasks { load "tasks/paperclip.rake" }
end
class Railtie
def self.insert
Paperclip.options[:logger] = Rails.logger if defined?(Rails)
Paperclip.options[:logger] = Rails.logger
if defined?(ActiveRecord)
Paperclip.options[:logger] = ActiveRecord::Base.logger
ActiveRecord::Base.send(:include, Paperclip::Glue)
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema)
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment