I’m trying the following tutorial: http://henrik.nyh.se/2007/03/ruby-wordwrap-method
It has a block that needs to be added somewhere I think outside of the helper:
class String
# Replace the second of three capture groups with the given block.
def midsub(regexp, &block)
self.gsub(regexp) { $1 + yield($2) + $3 }
end
end
Where should that be located in the rails 3 app? Thanks
UPDATE
Added /lib/midsub.rb
# Needed for html_format try 3
class String
# Replace the second of three capture groups with the given block.
def midsub(regexp, &block)
self.gsub(regexp) { $1 + yield($2) + $3 }
end
end
application.rb
config.autoload_paths += %W(#{config.root}/lib)
you can add that code inside a file, let’s say ‘my_string.rb’ in the /config/initializers folder