Since you are using Rails 4, the recommended way to share code between your controllers is to use the Controller Concern. Controller concerns are modules that can be mixed with controllers to share code between them. Therefore, you must include the common helper methods in the controller and include the anxiety module in all your controllers where you need to use the helper method.
In your case, since you want to share method3 between two controllers, you have to worry about it. See this tutorial to learn how to create problems and share codes / methods among controllers.
Here are some codes to help you jump:
Identify the problem with the controller:
# app/controllers/concerns/your_controller_concern.rb module YourControllerConcern extend ActiveSupport::Concern included do helper_method :method3 end def method3
Then include care in your controllers:
class CartsController < ApplicationController include YourControllerConcern
Now you can use method3 in both controllers.
source share