I have two controllers in different namespace(a and b), like below:
class A::TechnologiesController < ApplicationController def index render json: Technology.all end end class B::TechnologiesController < ApplicationController def index render json: Technology.all end end The two actions execute the same logic, and I belive it is a repetition. I want to eliminate the repetition, so how can I borrow the code in namespace a like below?
class B::TechnologiesController < ApplicationController def index A::TechnologiesController.method(:index).call self end end
class A::TechnologiesController < BaseTechnologiesController) or include a module that provides the methods.