Check out js_regex, my Ruby gem for translating Ruby regexes to JavaScript:
https://github.com/janosch-x/js_regex
Check out delete_recursively, my Ruby gem that speeds up deletion of dependent ActiveRecords:
https://github.com/janosch-x/delete_recursively