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

Coord y is being rendered as 'y' but x is still x #558

Open
sramsden opened this issue Apr 7, 2022 · 1 comment
Open

Coord y is being rendered as 'y' but x is still x #558

sramsden opened this issue Apr 7, 2022 · 1 comment

Comments

@sramsden
Copy link

sramsden commented Apr 7, 2022

I have a rails model with coords, and when dumped to yml the y is rendered incorrectly.

For example,

>> puts Coord.new(x: 13, y: 12).attributes.to_yaml
---
id:
x: 13
"y": 12

instead of the expected

>> puts Coord.new(x: 13, y: 12).attributes.to_yaml
---
id:
x: 13
y: 12

This comes about because of this change ...
6a1c306

I have commented out those lines and I get the expected coord rendered.
I'm not sure what the solution is because I know that change was added to appease yes/no boolean guff but unfortunately y is a known coordinate also 🤷

@tisba
Copy link

tisba commented Sep 9, 2022

That commit was the fix for #443.

Can you show, what the result of #attributes is that get's #to_yaml called on?

I'm assuming something like this (which is the correct behaviour IMO):

002 > puts({"x" => "1", "y" => "2"}.to_yaml)
---
x: '1'                                       
"y": '2'                                     
 => nil

I'm not exactly sure what the problem is, @sramsden. Unless you want the key to be interpreted as true (one of the unfortunate YAML spec attributes), then "y": 12 is "y" as a string key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants