Hi, I have a bunch of utility functions. If I put them in "controllers/application.rb" then they will be accessible from all controllers. If I put them in "helpers/application_helper.rb" then they will be accessible from all templates. But what if I need to access them from everywhere - controllers, views, even models? Where do I put them? Ingo Weiss -- Posted via http://www.ruby-forum.com/.
Ingo Weiss wrote:> Hi, > > I have a bunch of utility functions. If I put them in > "controllers/application.rb" then they will be accessible from all > controllers. If I put them in "helpers/application_helper.rb" then they > will be accessible from all templates. > > But what if I need to access them from everywhere - controllers, views, > even models? Where do I put them?Sling''em in lib/. They''ll get automatically required. -- Alex
> Sling''em in lib/. They''ll get automatically required.Now I have a file "lib/utilities", with my function definitions in it. I still get a "no method" error when attempting to use the functions. Is there anything else I need to do? Ingo -- Posted via http://www.ruby-forum.com/.
You need to name the file: lib/utilities.rb -- -- Tom Mornini On Apr 27, 2006, at 2:09 AM, Ingo Weiss wrote:>> Sling''em in lib/. They''ll get automatically required. > > > Now I have a file "lib/utilities", with my function definitions in > it. I > still get a "no method" error when attempting to use the functions. Is > there anything else I need to do? > > > Ingo > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails