Forum: Ruby on Rails shared methods for controllers belonging to a specific modul

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.
Ac7ff1e49fdefdaf75f4e46be5d1cdff?d=identicon&s=25 rails.list (Guest)
on 2005-12-03 03:31
(Received via mailing list)
Hi everyone.

I was just wondering what the best way â?¢ might be to let all controllers
of a module share methods and variables. Is there some "magic" file
rails will automatically load when a module is requested or do I have to
manually (doesn't sound like the rails way..) create a class with the
desired methods/variables and let my controllers inherit from it? If so,
where to put that file in order to let rails do some autoload magic?

Regards,
Niels.
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 petermichaux (Guest)
on 2005-12-03 07:03
(Received via mailing list)
I was asking about the same thing but for models instead of controllers.
I
was told to put the shared code in a Ruby module in a file in the lib
directory and then include the module in the desired model. The files in
the
lib directory seem to be loaded and available automatically. But I have
to
restart WEBrick each time I change a file in lib/.

Peter
This topic is locked and can not be replied to.