-
Notifications
You must be signed in to change notification settings - Fork 1
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
The key for the errors hash is a string, not a symbol in Rails 4 #3
Comments
Hi @zonotope, sorry for the difficulties! Out of interest what Ruby version are you using? Perhaps this is the cause of the difference. I'm not sure converting it to string keys will be the answer as it is working for me (tm) right now with symbols, we could however run a It could also be your Rails version, but I'm also using Rails 4 and this isn't a problem, could you |
Thanks a lot! my rails version is: |
i also think that |
Great! I think it might be time to add Rails version specific test runs too, will help find these issues in future, I'll try to get to this asap, could you trial Its a little worrying it converted to a normal hash, might need to run a |
Hi again @tommeier. Sorry for the delay. I took a break from this particular project, but I'm back on it now. Calling In The problem is that this, just like the attributes hash, is just a plain old hash. The parameters are stored in the session between requests, and according to this, the server might not be able to reconstruct complex objects from the session that were stored across requests. I'm not sure if Do you have any ideas about how to get around this? |
@zonotope interesting, what session store are you using? |
We're using the cookie store, and it all makes sense now. That's why it's always just a plain Hash on read. |
aha! Yes, that will be it @zonotope , We're using a database session store (mostly for security reasons) and that would explain the difference in behaviour. This might be a bit trickier to resolve, I'll need to spend some time thinking over any potential security implications over passing the values via cookie based session before jumping into any changes. |
yeah, it is definitely riskier to store the data in cookies, but it's probably fine. in any case, i think we can safely switch over to the active record store in the meantime since our app isn't going to have to face too much traffic initially. thanks a lot. |
Fantastic thanks @zonotope , I'll leave this open as I definitely want to think this through and come up with a cookie friendly solution. |
@zonotope one possible solution would be to use :marshal as the cookie serialisation option:
|
I've been trying to integrate rails-prg into my app, and I've been debugging a nil pointer issue with the
load_redirected_objects
callback. I've isolated the problem to an attempt to reference the redirected instance'serrors
hash with a symbol instead of a string here. After stepping through the request, it looks like what's happening is that when the relevant model instance is serialized into the flash withset_redirected_object!
, both the:error
and:params
symbol keys are converted to string. I have verified that if I changeload_redirected_objects!
to access the errors and params sub-hashes with string keys instead of symbol keys, that things work as expected. Would you accept a patch with this small change and, if not, is there something less invasive that I can do to get this to work properly?The text was updated successfully, but these errors were encountered: