If I’ve got a method in a different controller to the one I’m writing in, and I want to call that method, is it possible, or should I consider moving that method to a helper?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could technically create an instance of the other controller and call methods on that, but it is tedious, error prone and highly not recommended.
If that function is common to both controllers, you should probably have it in
ApplicationControlleror another superclass controller of your creation.Yet another way to do it as jimworm suggested, is to use a module for the common functionality.