How to access TextHelper from Lib?

Hi,

I’ve written a class sitting in a file in the Lib directory and this
class needs to use strip_tags from TextHelper. I’ve added

include ActionView::Helpers::TextHelper

to the class but Ruby complains that the method strip_tags doesn’t
exist. How can I access ActionView methods from a a class in Lib?

Thanks.

Donut D. wrote:

I’ve written a class sitting in a file in the Lib directory and this
class needs to use strip_tags from TextHelper. I’ve added

include ActionView::Helpers::TextHelper

to the class but Ruby complains that the method strip_tags doesn’t
exist. How can I access ActionView methods from a a class in Lib?

Are you trying to call strip_tags from a class or instance context?
If you want to add the helpers as class methods, instead use

 extend ActionView::Helpers::TextHelper


We develop, watch us RoR, in numbers too big to ignore.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs