How to remove backslashes in string generated through .to_json function. Rails 3.2
It's much better to use as_json
instead. Provides the json without backslashes.
For reference, http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html
You can just gsub!
to replace the \"
with a single quote '
, like so:
a.gsub!(/\"/, '\'')