How do I make the following method available in the view layer?
# app/controllers/base_jobs_controller.rb
class BaseJobsController < ApplicationController
def self.filter_name
(controller_name.singularize + "_filter").to_sym
end
end
I want to use it in a view helper like this:
module ApplicationHelper
def filter_link(text, options = {})
# Need access to filter_name in here....
end
end
Instead of
helper_method, I prefer to include such functionality in a module.Then include the module in the
BaseJobsControllerandApplicationHelper.Depending on the content of your methods in the module, you may need to use an alternative method to access certain data (ie. the current controller’s name).