Thanks, that worked for me.  I'm not able to upgrade to RC1 quite yet.

Cheers,

-Will


On Aug 3, 3:20 am, Huet <[email protected]> wrote:
> Hi All,
>
> I have had this problem with Rails 3 and 1.9.1. The fix for this error
> is to add  to_a to the json call.
>
> render :json => {:top => @top.to_a.as_json(:only => [:id, :title ] ) }
>
> Hope this helps.
>
> Huet
>
> On Aug 3, 8:01 am, Conrad Taylor <[email protected]> wrote:
>
>
>
> > On Mon, Aug 2, 2010 at 2:26 PM, wprater <[email protected]> wrote:
> > > Here is my model and an attempt to convert to json.  Whether there is
> > > data returned or not, acircularreference error is thrown.  How can I
> > > avoid this?
>
> > wprater, I would recommend trying Rails 3 RC by doing the following:
>
> > gem install rails --pre
>
> > Also, if you don't have a requirement to use Ruby 1.8.7, I would recommend
> > using Ruby 1.9.2 RC2 by doing the following:
>
> > rvm install 1.9.2
>
> > Ryan Bates recently added the following screencast which covers the
> > installation
> > of both Rails 3 and Ruby 1.9.2.
>
> >http://media.railscasts.com/videos/225_upgrading_to_rails_3_part_1.mov
>
> > Good luck,
>
> > -Conrad
>
> > > ruby-1.8.7-p249 > PayPeriod
> > >  => PayPeriod(id: integer, start_date: date, end_date: date, pay_date:
> > > date)
> > > ruby-1.8.7-p249 > PayPeriod.where('end_date < ?', Time.now)
> > >  => []
> > > ruby-1.8.7-p249 > PayPeriod.where('end_date < ?', Time.now).to_json
> > > ActiveSupport::JSON::Encoding::CircularReferenceError: object
> > > references itself
> > >        from /Users/wprater/.rvm/gems/ruby-1.8.7-p249/gems/
> > > activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:59:in
> > > `check_for_circular_references'
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Ruby on Rails: Talk" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<rubyonrails-talk%2Bunsubscrib
> > >  [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to