michaeldv/awesome_print — Issue #68: AP Conflict with Paperclip in Rails Console
Author: thrillcall
Created: 2011-12-16 22:01:38+00:00
State: open

We are experiencing a strange issue in our development environment when using AP in the rails console.

When my ~/.irbrc file contains the following snippet, as recommended in the AP docs, we are unable to upload images in our dev env using Paperclip:

```
# FIXME : Removed since it was conflicting with PaperClip!?
#
# AWESOME PRINT
#require "ap"
#unless IRB.version.include?('DietRB')
# IRB::Irb.class_eval do
# def output_value
# ap @context.last_value
# end
# end
#else # MacRuby
# IRB.formatter = Class.new(IRB::Formatter) do
# def inspect_object(object)
# object.ai
# end
# end.new
#end
```

Removing this snippet resolves the issue completely. Otherwise the rails console will hang w/ 100% CPU usage until a control-c is given to break out of it. I turned to awesome_print changes to fix our problem due to the backtrace I saw in the console after control-c. The backtrace.

```
>> arp = ArtistPhoto.create(:image => File.open(Rails.root.to_s + '/public/images/twitter.png', 'rb'), :artist_id => 1)
^CIRB::Abort: abort then interrupt!!
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/aws/models/storage/file.rb:75:in `call'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/aws/models/storage/file.rb:75:in `owner='
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/attributes.rb:144:in `block in merge_attributes'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/attributes.rb:141:in `each'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/attributes.rb:141:in `merge_attributes'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/model.rb:10:in `initialize'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:105:in `new'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:105:in `new'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/aws/models/storage/files.rb:105:in `new'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:92:in `block in load'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:91:in `each'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:91:in `load'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/aws/models/storage/directories.rb:33:in `get'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/aws/models/storage/files.rb:32:in `all'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:131:in `lazy_load'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/fog-1.0.0/lib/fog/core/collection.rb:18:in `=='
... 27 levels...
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:26:in `format'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/inspector.rb:104:in `unnested'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/inspector.rb:71:in `awesome'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:144:in `block (2 levels) in awesome_object'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:297:in `indented'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:143:in `block in awesome_object'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:131:in `map'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:131:in `awesome_object'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:56:in `awesome_self'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/formatter.rb:28:in `format'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/inspector.rb:104:in `unnested'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/inspector.rb:71:in `awesome'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
from /Users/glenn/.rvm/gems/ruby-1.9.2-p290@thrillcall/gems/awesome_print-1.0.1/lib/awesome_print/core_ext/kernel.rb:15:in `ap'
from /Users/glenn/.irbrc:51:in `output_value'
from /Users/glenn/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `

'>> quit
```

Commenting out the console integration completely resolves the issue. Any thoughts?

Rails 2.3.14 with the following related gems:

```
gem "paperclip", "2.4.5"
gem "delayed_paperclip", "2.4.5.1"
gem "paperclip-meta", "0.2"
gem "awesome_print", "1.0.1"
gem "fog", "1.0.0"
```