beerlington/classy_enum — Issue #6: CircularReferenceError with rails 'to_json' method
Author: ghostd
Created: 2011-10-25 16:02:26+00:00
State: open

Hi,

I added an enum to my (working) class, and now i get CircularReferenceError when i try to convert my instance into JSON.

By default class is serialized with the enum, which is serialized with the owner... which is serialized with the enum :-)

I think the generator (or the base class) should override as_json to except the owner attribute.

I did this into by base enum class:
def as_json(options = {})
{:sym => to_s, :name => name}
end