# To\_json not working because reflections are wrong

**URL:** <https://www.ruby-forum.com/t/to-json-not-working-because-reflections-are-wrong/195625>\
**Category:** Rails\
**Created:** [September 27, 2010, 9:13am UTC](https://www.ruby-forum.com/t/to-json-not-working-because-reflections-are-wrong/195625 "2010-09-27T09:13:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bodo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3da27b/32.png) [@Bodo\_T](https://www.ruby-forum.com/u/Bodo_T)\
**Post date:** [September 27, 2010, 9:13am UTC](https://www.ruby-forum.com/t/to-json-not-working-because-reflections-are-wrong/195625/1 "2010-09-27T09:13:10Z")

</div>

I have a class called “Foo” that looks like this:

class Foo \< ActiveRecord::Base  
belongs\_to othermodel  
end

and a class “Bar” that looks like this:

class Bar \< Foo  
belongs\_to thirdmodel  
end

When i try to serialize bar with : bar.first.to\_json(:include  
=\> :othermodel), it fails in production mode. Strangely it works in  
the development environment. I digged around and found that the  
bar.first.class.reflections.keys only includes “thirdmodel” and not  
“othermodel” in production mode.

I can’t explain that, in rails 2 and in the development environment it  
works prefect.
