Navigation Menu

Skip to content

Commit

Permalink
In the effort of decoupling Rails from unit specs, you can't have any…
Browse files Browse the repository at this point in the history
… code that calls `Rails` (since it isn't available). In my unit specs that need Paperclip, I call `Paperclip::Railtie.insert` and all is good :)
  • Loading branch information
Justin Ko committed Feb 1, 2012
1 parent 1cb40e3 commit 67d5c0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/railtie.rb
Expand Up @@ -18,15 +18,15 @@ class Railtie < Rails::Railtie

class Railtie
def self.insert
Paperclip.options[:logger] = Rails.logger

if defined?(ActiveRecord)
ActiveRecord::Base.send(:include, Paperclip::Glue)
Paperclip.options[:logger] = ActiveRecord::Base.logger

ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema)
else
Paperclip.options[:logger] = Rails.logger
end

File.send(:include, Paperclip::Upfile)
Expand Down

0 comments on commit 67d5c0b

Please sign in to comment.