helper_method is useful when functionality is what is used both between the controller and the view. A good example is current_user .
If the method is more related to the logic of the controller rather than formatting, then it belongs to the controller. Something like current_user will be shared among all controllers, so it must be defined in ApplicationController .
The true “helper” methods relate to the view and handle things like formatting and template logic. They are rarely needed in the controller, and they belong to their own module under the application / helpers. You can include them in your controller when necessary, but in the end you will get a class support method available for your controller available to your controller.
Andrew Vit Aug 23 '10 at 16:46 2010-08-23 16:46
source share