Skip to content
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

Make Parameters support legacy YAML encodings. #26017

Merged

Commits on Aug 1, 2016

  1. Make Parameters support legacy YAML encodings.

    By changing ActionController::Parameter's superclass, Rails 5 also changed
    the YAML serialization format.
    
    Since YAML doesn't know how to handle parameters it would fallback to its
    routine for the superclass, which in Rails 4.2 was Hash while just Object
    in Rails 5. As evident in the tags YAML would spit out:
    
    4.2: !ruby/hash-with-ivars:ActionController::Parameters
    5.0: !ruby/object:ActionController::Parameters
    
    Thus when loading parameters YAML from 4.2 in Rails 5, it would parse a
    hash dump as it would an Object class.
    
    To fix this we have to provide our own `init_with` to be aware of the past
    format as well as the new one. Then we add a `load_tags` mapping, such that
    when the YAML parser sees `!ruby/hash-with-ivars:ActionController::Parameters`,
    it knows to call our `init_with` function and not try to instantiate it as
    a normal hash subclass.
    kaspth committed Aug 1, 2016
    Copy the full SHA
    31448f2 View commit details
    Browse the repository at this point in the history