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

Don't call to_json on string props #791

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project's source code will be documented in this fil
Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.

## [Unreleased]
## [6.9.3] - 2017-04-03

### Fixed
- Removed call of to_json on strings when formatting props. [#791](https://github.com/shakacode/react_on_rails/pull/791) by [justin808](https://github.com/justin808)

## [6.9.2] - 2017-04-02

Expand Down Expand Up @@ -518,7 +522,8 @@ Best done with Object destructing:
##### Fixed
- Fix several generator related issues.

[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.9.2...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.9.3...master
[6.9.3]: https://github.com/shakacode/react_on_rails/compare/6.9.1...6.9.3
[6.9.2]: https://github.com/shakacode/react_on_rails/compare/6.9.1...6.9.2
[6.9.1]: https://github.com/shakacode/react_on_rails/compare/6.8.2...6.9.1
[6.9.0]: https://github.com/shakacode/react_on_rails/compare/6.8.2...6.9.0
Expand Down
6 changes: 5 additions & 1 deletion app/helpers/react_on_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ def json_safe_and_pretty(hash_or_string)
#
# Temp fix given that a hash may contain active record objects and that crashed with the new
# code to JSON.pretty_generate
ERB::Util.json_escape(hash_or_string.to_json)

# If to_json is called on a String, then the quotes are escaped.
json_value = hash_or_string.is_a?(String) ? hash_or_string : hash_or_string.to_json

ERB::Util.json_escape(json_value)
# end
end

Expand Down