I'm happened to write create one file in lib folder and I want to use TextHelper in that file. How can I make Texthelper available?
Suggestions appreciated, Thanks,
Actually it's not that hard at all. You can just include the TextHelper
module from your class.
class MyLib
include ActionView::Helpers::TextHelper
def five_things(x)
pluralize 5, x
end
end
>> MyLib.new.five_things "dog"
=> "5 dogs"
That's from a class I defined in lib
, and output from a script/console
session to make sure it all plays nice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With