Thursday, July 15, 2010

rails - using truncate from a the lib dir ie a module

Here is how to get the helpers into the libs area, Sometimes the helpers use/set data on the controller etc so this doesn't work.

module MyModule
  include ActionView::Helpers::TextHelper
  module_function :truncate
end


Here is how to get it on the console
helper.truncate(string, :length => length)

No comments:

Post a Comment