Rails3 - How to Create a Custom Helper for Controllers and Views

Given a custom helper file in app / helpers / url_helper.rb

module UrlHelper ... end 

How to make it available in all controllers and in all views?

+6
ruby-on-rails
source share
2 answers

Put it in the ApplicationController (not an assistant) and declare helper_method :method_name .

+7
source share

Or ... include them in your controller

 class ApplicationController < ActionController::Base include UrlHelper end 
+11
source share

All Articles