Good long weekend everyone?
I've got a general question: what do you guys put into /lib? More
specifically: modules or classes?
I use classes, with class methods (is that even the right term for
Ruby?), such as:
class TimeUtils
def self.time_from_now
end
end
My problem is that I would like to include a TextHelper method
(pluralize in this case) and I can't figure out how to do that. I've
tried:
require File.dirname(__FILE__) + '/../vendor/rails/actionpack/lib/
action_view/helpers/text_helper'
class TimeUtils
def self.time_from_now
pluralize(1, "minute")
end
end
But I get:
NoMethodError: undefined method `pluralize' for TimeUtils:Class
Is there a way to include TextHelper?
Cheers
Cyrille
I've haven't personally seen anyone use helpers outside of views...
Hi,
Try :
# don't put the require line
class TimeUtils
extend ActionView::Helpers::TextHelper
# ...
end
-- Jean-François.
yeah, "extend" works. Thanks for that!
Cheers
Cyrille
On Oct 23, 1:39 pm, "Jean-François Trân" <jft...@rubyfrance.org>
wrote: