Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Serializing to JSON #41

Closed
retro opened this Issue · 7 comments

4 participants

@retro

Serializing to json, when using default to_json causes SystemStackError (stack level too deep). I believe that is because Uploader object holds reference to parent item.

@jnicklas
Owner

Added JSON serialization, Closed by 4f271aa

@jduff

I'm noticing this in Rails3 when using filesystem storage.

@jnicklas
Owner

Hmm. Can you provide more context? Stack traces or even better, failing specs would be awesome.

@jduff

I was trying to get the specs to run so I could write a failing one for this case but am having trouble with image_science so haven't been able to get them to run.

Here's the stack trace from my Rails app:

    from (irb):24ruby-1.8.7-p299 > Recipe.first.to_json(:except=>{:photo=>:owner})

SystemStackError: stack level too deep
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activerecord-3.0.0.rc/lib/active_record/attribute_methods/read.rb:80:in read_attribute'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activerecord-3.0.0.rc/lib/active_record/base.rb:1496:in
attributes'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activerecord-3.0.0.rc/lib/active_record/base.rb:1496:in each'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activerecord-3.0.0.rc/lib/active_record/base.rb:1496:in
attributes'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activemodel-3.0.0.rc/lib/active_model/serialization.rb:71:in serializable_hash'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activerecord-3.0.0.rc/lib/active_record/serialization.rb:13:in
serializable_hash'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activemodel-3.0.0.rc/lib/active_model/serializers/json.rb:83:in encode_json'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:46:in
encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:60:in check_for_circular_references'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:45:in
encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in encode_json'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/carrierwave-52718d0/lib/carrierwave/mount.rb:24:in
map'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in each'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in
map'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in encode_json'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:46:in
encode'
... 3173 levels...
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in encode_json'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/bundler/gems/carrierwave-52718d0/lib/carrierwave/mount.rb:24:in
map'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in each'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in
map'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:209:in encode_json'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:46:in
encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:60:in check_for_circular_references'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:45:in
encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:30:in encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activemodel-3.0.0.rc/lib/active_model/serializers/json.rb:89:in
encode_json'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:46:in encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:60:in
check_for_circular_references'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:45:in encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/json/encoding.rb:30:in
encode'
from /Users/johnduff/.rvm/gems/ruby-1.8.7-p299@rails3/gems/activesupport-3.0.0.rc/lib/active_support/core_ext/object/to_json.rb:15:in `to_json'

@stephenhandley

i'm currently getting the same issues using filesystem store with
gem 'rails', '3.0.0'
gem 'carrierwave', :git => "git://github.com/jnicklas/carrierwave.git"
gem 'mini_magick'

@jnicklas
Owner

@stephenhandley could you also post a stack trace please?

@stephenhandley

hey sorry just created a new issue here with the stack trace
http://github.com/jnicklas/carrierwave/issues#issue/130

@j1mr10rd4n j1mr10rd4n referenced this issue from a commit in j1mr10rd4n/carrierwave
@jnicklas jnicklas Added JSON serialization, Closes #41 4f271aa
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.