-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
[Bug 1.10.0] Issue with frozen strings #53
Comments
Thanks for the report. Was this not a problem in v1.9.0 as well, or was this problem introduced in v1.10.0? |
Hi, I am cleaning a string: template = StripAttributes.strip(template, collapse_spaces: true) FrozenError: can't modify frozen String It might happens because And it works in old version. |
When I downgrade to 1.9.2 then problem is gone. The problem is that string value can be frozen and bang methods raise. |
I didn't look up in rails code for enums, but I think, that rails freezes all enum values. So yes, problem is not with enums itself but with frozen strings generally. |
Hi all, I'm inclined to think that the desired behavior here would be to ignore frozen strings. i.e. Short-circuit with a guard clause if the string is frozen. Thoughts? Aside, I'm a little confused why this behavior exists in 1.10.0, but not 1.9.x, but I'll dig in with some tests. |
We're seeing this too, with frozen strings coming from a different source than enums. The behavior in 1.9.x would have been equivalent to adding Short-circuiting on .frozen? in some way makes sense, but it is a definite breaking behavior change from 1.9, and so in my opinion should be reserved for a 2.0 release. For 1.10.x, I recommend adding Looks like you may already be on this, but if you want me to prepare a PR to fix 1.10.x, let me know. |
1.9 does not have bug because of value = value.strip if value.respond_to?(:strip)
I think a guard for a frozen string is the best solution, but I agree with @zarqman that for now it is best to just |
I'm going to do two things here.
|
In 1.10.0 there is an issue with models that have
enum
attribute. For example:IRB:
Rails_admin controller log:
If I downgrade to
1.9.2
the issue is gone.1.9.2 had this code
that automatically created new unfrozen value.
So possible solution might be to add here
The text was updated successfully, but these errors were encountered: