How to call ApplicationController methods from ApplicationHelper

Use helper_method.

By default, methods in ApplicationController are only accessible inside the Controllers.

Add a method to the ApplicationController and expose it as a helper method with helper_method:

class ApplicationController < ActionController::Base

  helper_method :foo

  def foo
    "bar"
  end

end

Now the foo method is accessible to both Controllers and Views.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)