class String def escape_single_quotes self.gsub(/[']/, '\\\\\'') end end
Useful if you ever get the idea of shoving Ruby strings into JavaScript code.
12362 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
class String def escape_single_quotes self.gsub(/[']/, '\\\\\'') end end
You need to create an account or log in to post comments to this site.
http://rails.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000440