Answer the question
In order to leave comments, you need to log in
How to correctly call a controller method from another controller?
Hello. Tell me please. How to correctly call a method from another controller.
Which option is preferable
1) make the method public through ApplicationController
2) call it by creating an object Institution::MenuRequirementsController.new.update_prices()
3) or declare the method through self, and then call it Institution::MenuRequirementsController.update_prices
Or is there another solution. Thanks
Answer the question
In order to leave comments, you need to log in
If the method is shared, then you can either move it to a common parent, or move it to a module/concern and connect it further in the standard way.
Such a task should not arise, your design approach is not correct. You can use trailblazer opertaion , dry-transaction or dry-contaioner to take some common functionality out. Everything depends on the task.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question