Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move Schema includes into Paperclip::Glue

  • Loading branch information...
commit e59d0b530b80a7a2c18ed4c1bc2330b6ea758322 1 parent ec1aa8b
@sikachu sikachu authored
Showing with 12 additions and 7 deletions.
  1. +8 −0 lib/paperclip/glue.rb
  2. +4 −7 lib/paperclip/railtie.rb
View
8 lib/paperclip/glue.rb
@@ -1,4 +1,6 @@
require 'paperclip/callbacks'
+require 'paperclip/validators'
+require 'paperclip/schema'
module Paperclip
module Glue
@@ -8,6 +10,12 @@ def self.included base #:nodoc:
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
View
11 lib/paperclip/railtie.rb
@@ -3,27 +3,24 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.