How to define helper method in my Rails module?

Im using Rails 4.2.4. How to define an auxiliary (private) method in a module? I have this module

module WebpageHelper def get_url(url) content = get_content(url) .. end def get_content(url) … end module_function :get_url end 

I do not want the get_content method to be public, but with the code above, I get an error

 Error during processing: undefined method `get_content' for WebpageHelper:Module 

How to define a private helper method in my module?

+7
methods module ruby-on-rails-4 helper
source share
1 answer

I think the best way (and basically how existing libraries are written) is to do this by making a class in a module that deals with all the logic, and the module simply provides a convenient method.

Documents are here;

Private method

Or look here for some good examples, for example. class << self .

+1
source share

All Articles