While I realize you are supposed to use a helper inside a view, I need a helper in my controller as I\'m building a JSON object to return.
It goes a little like this:
One alternative missing from other answers is that you can go the other way around: define your method in your Controller, and then use helper_method to make it also available on views as, you know, a helper method.
For instance:
class ApplicationController < ActionController::Base
private
def something_count
# All other controllers that inherit from ApplicationController will be able to call `something_count`
end
# All views will be able to call `something_count` as well
helper_method :something_count
end