-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
[Rails 3.2][v6.9.0] Parsing error when fetching ReactOnRails context from script tag #782
Comments
@cheremukhin23 It seems the changes don't work for Rails 3.x. @Ynote Any chance that you can try to submit a PR to fix this? @Ynote can you downgrade to 6.8.x. I suspect that Rails 3.2 is not compatible with the latest changes. def json_safe_and_pretty(something)
if Rails.env.development?
ERB::Util.json_escape(JSON.pretty_generate(something.as_json))
else
ERB::Util.json_escape(something.to_json)
end
end I'm puzzled by how this code left out the quotes for the strings. |
@Ynote Please see if the fix in 6.9.1 helps you. |
I have this problem with rails 5.0.2. |
@kulakowka @Ynote We're not seeing this on the https://github.com/shakacode/react-webpack-rails-tutorial nor with simple generated apps, all with Rails 5. Can you please create a reproduction scenario so we can fix this? |
I performed the following actions:
|
This is from shakacode/react-webpack-rails-tutorial#370 |
Apparently I forgot to update the gem. Here's how I fix this:
|
@justin808 sorry the late reply. I try to update to the version I have a big (and old) Rails application. I don't really know how to create a reproductible scenario. I'll try with a plain new app (on Rails 3.2) and check if I still have the bug. For the moment, I just downgraded to Thank you very much for you help. |
The problem is that npm itself has updated the package version. My version of the package.json was:
And Gemfile.lock
When I ran I think you should do a check or at least mention this in the documentation. |
@justin808 The output issue seems to be related to the We are trying to update the Rails version of our application but it is a huge task and it won't be done immediately. Do you have a suggestion for me to deal with that? |
@Ynote: I think we need to copy the code from the current version of that method and put in RoR and use that code for Rails version less than the version that is current. @kulakowka: When your rails app starts, it should be complaining if the versions don't match. Are you not seeing errors in the logs? @robwise Maybe we should throw an exception? CC: @cheremukhin23 |
@justin808 What does this error look like? |
Should be a logger.warn: msg = "**WARNING** ReactOnRails: ReactOnRails gem and node package MAJOR versions do not match\n" \
" gem: #{gem_version}\n" \
" node package: #{node_package_version.raw}\n" \
"Ensure the installed MAJOR version of the gem is the same as the MAJOR version of \n"\
"your installed node package." |
@justin808 I'll check it out on Monday. |
@robwise, @kulakowka: Maybe we should do a logger.error? |
@justin808 yes. It would be very convenient. |
Hi, I tried this branch and the fix works. But, I have to detail a little bit more what I have done because I ran into another error. When fetching the fix, I got another error when the helper parsed the In my props, I have something like this: {
entities: {
projects: {
byId: {
1282: project.find(1282),
1509: project.find(1509)
},
selected: [1509]
}
}
} Here, the I have so many other gems in my old RoR application that updating {
entities: {
projects: {
byId: {
1282: project.find(1282).to_json,
1509: project.find(1509).to_json
},
selected: [1509]
}
}
} It seems to work correctly. I don't know if what I've done is correct or if I could have done better. |
JSON.pretty_generate has been removed for now. @Ynote Please try 6.9.3. |
I ran in to this issue as well and 6.9.3 seems to have fixed it. |
Hi @justin808, I am really sorry for the late late reply. #791 is not enough in my stack to handle the issue. It doesn't work for me with |
@justin808 I just tested #787. It works perfectly with my stack. Thank you so much for your help and your investigation! |
Hi @justin808, I just pushed #812. I'm sorry, I didn't use Reviewable, I'm not used to it. I hope the PR will be ok. |
Just for the record on this issue: The eating quotes issue and the special characters More information about the fix: https://github.com/shakacode/react_on_rails/pull/812/files#diff-1958662b8ed5b2a812bdc2f427f01bc2R15. |
Hi,
I updated the gem to the version
6.9.0
so it can be compatible with the node module (6.9.0).I'm using it with Rails 3.2.
Unexpectedly, I got this parsing error:
This is the output I have in the
script
tag generated by the helperprepend_render_rails_context
:The generated output doesn't seem to be formatted as json so it cannot be parsed correctly by the javascript. Is there something that I should have done in my configuration?
Thank you very much for your help (and your great great project)!
The text was updated successfully, but these errors were encountered: