Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 759
Nerian Avatar asked Dec 15 '10 22:12

Nerian


People also ask

Can helper methods be used to transfer data from controller to view?

You can put a method in a controller and then call helper_method in the controller to indicate that this method is available as if it were in a helper too. This method will then be available to all controllers and to all views.

Where are custom view helpers stored in rails?

Custom helpers for your application should be located in the app/helpers directory.


1 Answers

Or... include them into your controller

class ApplicationController < ActionController::Base
  include UrlHelper
end
like image 154
iain Avatar answered Sep 28 '22 04:09

iain