On Feb 28, 12:38 am, Dudebot <[email protected]> wrote:
> On Feb 27, 5:10 pm, ben wiseley <[email protected]> wrote:> Just put it in a 
> helper and include that helper in ApplicationController
> > like this
>
> > include MyHelperWithGlobalStuffInIt
>
> You're right, putting
>
> include ApplicationHelper
>
> into application_controller.rb does the trick.
>
> But wasn't that what
>
> helper :all # include all helpers, all the time
>
> was supposed to do?
>
> Or do I misunderstand?

You do :-). The helper method controls which of your helpers (in app/
helpers) are available to the views for that controller. Without the
helper :all call, by default views rendered by foo_controller will get
helper methods from foo_helper. You can name specific modules, so for
example if you a bunch of common helpers in app/helpers/
common_helpers.rb then you say helper :common_helpers or helper
CommonHelpers to add that module for the controller in question.

helper :all means add all of the helpers from app/helpers to all of
your views.

Another way of solving the original problem is declaring the method in
application_controller and then saying

helper_method :some_helper

which takes the named controller method and makes it into a view
helper.

Fred

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to