Here is my model and an attempt to convert to json. Whether there is
data returned or not, a circular reference error is thrown. How can I
avoid this?
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment