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

Saving show.json.jbuilder with UTF-8 BOM causes Rails error "unexpected keyword_ensure, expecting end-of-input ensure" #454

Open
MSCAU opened this issue Feb 16, 2019 · 2 comments

Comments

@MSCAU
Copy link

MSCAU commented Feb 16, 2019

I am using UltraEdit 25.20 as my text editor in Windows 10. I changed save settings yesterday to get around a UTF-8 display issue. It doesn't negatively affect any other file in my project, but the Jbuilder template now fails after saving it today.

There are a number of encoding options when saving, including:

  • UTF-8 (with BOM)
  • UTF-8 no BOM

These are explained quite well here: https://www.ultraedit.com/support/tutorials-power-tips/ultraedit/unicode.html

The former causes a server error when trying to load the JSON from a browser (eg. localhost/widgets/123.json) with an unhelpful error message:

syntax error, unexpected keyword_ensure, expecting end-of-input ensure

The latter works fine. Given that this only seems to affect JBuilder files, I thought this might be an issue for you.

In the interim I'll choose the "no BOM" option when saving JBuilder files. I may try https://github.com/amatsuda/jb which may or may not have the same issue.

@MSCAU
Copy link
Author

MSCAU commented Feb 17, 2019

I should add that the error changes but the underlying cause is the same. I have tidied up the file and the error (when saving "with BOM") is now:

undefined local variable or method `' for #<#Class:0x000000000e46c0b8:0x000000000d3f3650>

And If I reduce it to the bare minimum:

json.(@widget, :id)

the error is:

undefined local variable or method `json' for #<#Class:0x000000000e46c0b8:0x0000000011c899f0>
Did you mean? json
JSON

@MSCAU
Copy link
Author

MSCAU commented Feb 17, 2019

Ah! Jb has the same issue with the BOM.

I was interested to read adobe/brackets#10583

I am turning off the "Write UTF-8 BOM header to all UTF-8 files when saved" option in UltraEdit. I am also turning off "Automatically detect encoding".

If anything else comes up, I'll come back to this issue.

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

No branches or pull requests

1 participant