Forum: Ruby on Rails HELPERS_DIR is missing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D22781eccd92073acd6a1ed350c3d136?d=identicon&s=25 boblu (Guest)
on 2008-10-31 09:00
(Received via mailing list)
In my project, I have

class ApplicationController < ActionController::Base
  helper :all
end

module ApplicationHelper
   def use_module
        ### ssss
   end
end

class B < ApplicationController
   def efd
      call_private()
   end

   private
   def call_private()
      use_module()
   end
end

When I call B::efd(), an error return saying 'use_module()' is
undefined !!

I was wonderring why 'helper :all' in my application.rb is not working
at all.
Then I find that this method is depend on  'HELPERS_DIR' variable.
However, when I type this 'HELPERS_DIR'  in console, it shows
'uninitialized constant' error.

Does anyone has the same problem?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-31 09:19
(Received via mailing list)
On 31 Oct 2008, at 07:59, boblu <boblucn@gmail.com> wrote:

>   end
>   end
> end
>
> When I call B::efd(), an error return saying 'use_module()' is
> undefined !!
>
Helper methods are added to views, not controllers

Fred
D22781eccd92073acd6a1ed350c3d136?d=identicon&s=25 boblu (Guest)
on 2008-10-31 09:29
(Received via mailing list)
But sometimes, we need some methods that both used in view and
controller.
Where do you suggest to put them in?

On Oct 31, 5:18 pm, Frederick Cheung <frederick.che...@gmail.com>
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-31 09:43
(Received via mailing list)
On Oct 31, 8:28 am, boblu <bobl...@gmail.com> wrote:
> But sometimes, we need some methods that both used in view and
> controller.
> Where do you suggest to put them in?
>
You can make controller methods available to views with helper_method,
or you could have a module that you both include in a controller and
pass to  helper (which among other things adds a module to the set of
helpers a view has).

Fred
D22781eccd92073acd6a1ed350c3d136?d=identicon&s=25 boblu (Guest)
on 2008-10-31 09:59
(Received via mailing list)
ok, I see. Thank you.

I just think that "a module that both include in a controller and a
helper" is a little bit complicated then just write that method in
helper and make controller can access it, in the case that the number
of this kind of methods is not a big one.

Emm, maybe this is not the correct ruby way of doing things.
And maybe I should re-orgnize my app structure like your suggestion.
Thank you.

On Oct 31, 5:42 pm, Frederick Cheung <frederick.che...@gmail.com>
This topic is locked and can not be replied to.