I've googled around looking for answers to this simple question, with
little success.
How do I go about using a view helper from another controller, without
putting the helper into application_helper.rb? For example, I would
like to render a partial from the Products controller, when I am in a
Manufacturer view. I'd like to keep the helper function in
products_helper, but haven't found a way to. Putting everything into
the application helper just seems to make it really cluttered, and
just about everything ends up there, eventually.
How do I go about using a view helper from another controller, without
putting the helper into application_helper.rb? For example, I would
like to render a partial from the Products controller, when I am in a
Manufacturer view. I'd like to keep the helper function in
products_helper, but haven't found a way to. Putting everything into
the application helper just seems to make it really cluttered, and
just about everything ends up there, eventually.
Put it in app-helper.
If you got clutter, make certain you move as much as you can to the Models!
But a big issue with Rails is you can't plug-and-play controllers with their partials. If a partial gets shared into another controller's view - boom - the shared code has to go up that ol' stairway to heaven.
I've googled around looking for answers to this simple question, with
little success.
How do I go about using a view helper from another controller, without
putting the helper into application_helper.rb? For example, I would
like to render a partial from the Products controller, when I am in a
Manufacturer view. I'd like to keep the helper function in
products_helper, but haven't found a way to. Putting everything into
the application helper just seems to make it really cluttered, and
just about everything ends up there, eventually.
I'm not sure what's not working exactly, which probably means I'm
misunderstanding the setup. Is this correct?
The action is in the manufacturer controller.
The view template is in views/manufacturer.
The view renders a partial from views/products.
That partial calls a method from products_helper.rb.
I'd expect that to work fine. Am I describing it wrongly?
I see... Sorry for my ignorance - I wasn't familiar with the 'helper'
keyword, although I had investigated 'include' and 'require'. This is
exactly what I needed to know. Thanks!