Using helper methods outside views

On Rails-2.1 or later, you can use helper methods outside of views such as in controllers or models like below.

In class level of controllers or in models:

ApplicationController.helpers.<helper method>

In instance methods of controllers:

self.class.helpers.<helper method>

Source:
Module: ActionController::Helpers::ClassMethods

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.