ruby on rails - Factor out application_helper -


On my latest rail application, I have decided to only partially present with helpful methods.

For example, in application_helper.rb :

def render_header render: partial = & gt; "Partial / header" end

I'm doing to make my code a bit dry, if I change partial name or partial to display in extra logic is.

The flaw on this is that it quickly increases application_helper.rb, which flows very rapidly without doing so already.

I am wondering what is the best way to break application_helper. I was thinking that I should make an application_helpers library in lib /, and I want to include a separate module for each type of assistant, for example, partial_hrpper. RB

However, I could not get it to work. I have placed the file in lib / application_helpers / partial_helper.rb, and I have called the module "ApplicationHelpers :: PartialHelper" I thought it was automatic By the way the train will be loaded, and in my thoughts I can do "partial Helper.render_header", but I get an error that this method is not undefined on partial helper.

In another idea / help_helper.rb requires help, and calls it in my thoughts normally, but it also does not work.

Any ideas / solutions?

Thanks, Zack

You can app & lt ; Whatever & gt; _helper.rb can keep the file / assistants and the train will pick it up. You may have partials_helper.rb , for example. You are not restricted to an application assistant or helpdesk generated by the administrator.

Example partials_helper.rb :

  Module partial helper def render_header ... End End  

Comments