Rails helper modules in controller
helper, ruby, ruby-on-rails
Solution
If you really want to use helper methods in controller, you can treat your helper as regular Ruby module (which it is, honestly) and use `include`:
class Cars::EnginesController < ApplicationController
include Cars::EnginesHelper
# ...
end
Problem
I have a controller, I want to create a helper for this controller that I can use without including it. I tried creating a helper with the same name as the controller like so ``` class Cars::EnginesController < ApplicationController def start_engine check_fuel end end ``` and the helper that i created was ``` module Cars::EnginesHelper def check_fuel logger.debug("cheking fuel") end end ``` and the error that i got was ``` undefined local variable or method `check_fuel' for #<Cars::EnginesController:0x1160e8c80> ``` is there any conventions that i am missing out?