I have the following controller:
class FirstController < ApplicationController
helper_method :contoller_method
private
def contoller_method
"text"
end
end
How can I use contoller_method in the view of another controller? Is there a best practice?
Place the method in the
application_controller.rb. Then it’ll be available to all your controllers.If you only wanted to share it between two classes you could do something like this. Create a new controller called helper controller and have the First/Second controller inherit from it.