move string replacement to a ruby method
fix ruby methods for replacing links