Nerian
Nerian

Reputation: 16197

Rails3 – How do I make a custom Helper available to controllers And Views

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

module UrlHelper
  ...
end

How do I make it accessible in all controllers and in all views?

Upvotes: 7

Views: 3873

Answers (2)

iain
iain

Reputation: 16284

Or... include them into your controller

class ApplicationController < ActionController::Base
  include UrlHelper
end

Upvotes: 12

Brian Rose
Brian Rose

Reputation: 1725

Place it in ApplicationController (not a helper) and declare helper_method :method_name.

Upvotes: 7

Related Questions