New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack overflow when using classy_enum in the render function #7
Comments
I have not seen that issue before. Could you post your MessageType enum class so I can try and reproduce it locally? |
Hi Pete, thanks for the quick reply. I should say that I have no evidence that this errors stems explicitly from classy_enum, it could well be related to other things in my setup (although I wouldn't know what else to guess...) the only kind of evidence I see is that when I comment out the Here's the enum code. pretty simple....
|
I can't think of anything off hand that would be causing since you are definitely using it the way it was intended. I'll dig into it more this evening and see if I can reproduce. |
Thanks, I appreciate it, I hope you can find something. I'm surprised by this as well and I can't imagine what could be causing this weird behavior. The only think not weird here is that it happens all the time consistently :( |
Have you tried upgrading to 1.3.1? I had fixed an issue in that version related to converting objects to JSON, and I'm wondering if that will fix your problem as well. |
1.3.1 fixes that for me thanks! |
Actually, there is still a small issue - or maybe just a question. |
I think it's the way that Rails automatically converts the object to JSON and was not something I considered. It probably makes sense for me to add an option that lets you choose whether you want the attribute represented as the value's string or as a JSON object. Not sure how I'd implement it yet, but I think something like this would make sense: classy_enum_attr :message_type, :serialize_as_json => false |
if you implement that it'd be cool. would certainly make the json response On Fri, Nov 11, 2011 at 6:25 PM, Pete B <
/Ran |
Just pushed an updated gem v 1.3.2 which adds the serialize_as_json option. I decided that the default should not serialize the enum object and simply returns a string. This means you will not need to make any changes to your code to get the behavior you were expecting. |
Awesome man, thanks! On Nov 12, 2011, at 10:51 PM, Pete B
|
Hi, I'm seeing some weird behavior that I can't explain and it seems to be related to classy_enum.
In my model I have:
And I have the required enums and everything and it seems to work great. (I've used classy_enum in the past, so it's not my first enum. Other times didn't render a model with enums though)
The problem is that when I want to render a @message in the controller I get a stack overflow and sometimes (but not always) a complete server crash with class_enum in the stack
It's hard to say what exactly is causing this.... but when I remove the classy enum definition in the model the crash doesn't happen.
Does this ring a bell? Have you any idea why is this or how to solve that?
thanks!
The text was updated successfully, but these errors were encountered: