From: Binh Ly [mailto:binh / pigbaby.net] 
# <a href="#" onclick="new
# Ajax.Request('/accounts/todo_lists/1/todo_items/2', 
# {asynchronous:true,
# evalScripts:true, parameters:'authenticity_token=' +
# encodeURIComponent('0523c2646f11e096ef9ecd2f6e5b41690f99fc39')
# }); return
# false;">Remove</a>
# How would I go about replacing the single quotes ', with a 
# backslash and
# single quote? \'

you can try harder ;)

puts "c'mon, it's cool!".gsub("'","\\\\'")
c\'mon, it\'s cool!
#=> nil

or simply just,

puts "c'mon, it's cool!".gsub("'"){"\\'"}
c\'mon, it\'s cool!