# ActiveSupport::JSON::CircularReferenceError in InvoiceContro

**URL:** <https://www.ruby-forum.com/t/activesupport-circularreferenceerror-in-invoicecontro/122116>\
**Category:** Rails\
**Created:** [December 4, 2007, 6:17pm UTC](https://www.ruby-forum.com/t/activesupport-circularreferenceerror-in-invoicecontro/122116 "2007-12-04T18:17:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [December 4, 2007, 6:17pm UTC](https://www.ruby-forum.com/t/activesupport-circularreferenceerror-in-invoicecontro/122116/1 "2007-12-04T18:17:25Z")

</div>

Hello again,

I’m trying to use a grid control from EXTjs with RoR, and I’m following  
some exampe I found on the web, and adapting to my test database …

I can’t see any row, the grid is only a poor line, I use other extjs in  
the same page, and they are ok.

Trying to debuging, I found that the error, or at least one error, is  
when I apply the json …

## Here’s the code:

If I comment the last line: render :text=\>return\_data.to\_json,  
:layout=\>false I don’t get any error.

Any clue of what’s wrong ?

thanks,

raimon

```
     return_data = Hash.new()
     return_data[:Total] = @invoice_pages.item_count
     return_data[:Movies] = @invoices.collect{|u| {:id=>u.id,
                                         :factura=>u.factura,
                                         :data=>u.data,
                                         :client=>u.tipus,
                                         :total_base=>u.total_base,
                                         :total_iva=>u.total_iva,
                                         :total=>u.total} }
    render :text=>return_data.to_json, :layout=>false
```

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [December 5, 2007, 12:05am UTC](https://www.ruby-forum.com/t/activesupport-circularreferenceerror-in-invoicecontro/122116/2 "2007-12-05T00:05:40Z")

</div>

On 04 Dec 2007, at 18:17, Raimon Fs wrote:

> ## Here’s the code:
> 
> If I comment the last line: render :text=\>return\_data.to\_json,  
> :layout=\>false I don’t get any error.
> 
> Any clue of what’s wrong ?

You’ll probably have dates in your data to output as json. It doesn’t  
always work in Rails 1.2.x (don’t know about Edge). You could look  
into jsonifier, iirc this plugin fixes these kind of problems.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [December 5, 2007, 9:30am UTC](https://www.ruby-forum.com/t/activesupport-circularreferenceerror-in-invoicecontro/122116/3 "2007-12-05T09:30:57Z")

</div>

Peter De Berdt wrote:

> On 04 Dec 2007, at 18:17, Raimon Fs wrote:
> 
> > ## Here’s the code:
> > 
> > If I comment the last line: render :text=\>return\_data.to\_json,  
> > :layout=\>false I don’t get any error.
> > 
> > Any clue of what’s wrong ?
> 
> You’ll probably have dates in your data to output as json. It doesn’t  
> always work in Rails 1.2.x (don’t know about Edge). You could look  
> into jsonifier, iirc this plugin fixes these kind of problems.
> 
> Best regards
> 
> Peter De Berdt

yes, it was a date problem as you suggests …

I see that I have some more bugs in my ext grid …

thanks for your info !

regards,

rai
