I have some things I''ll be using across multiple controllers (generic parameter checking / text processing type methods). I''m wondering where one should put this stuff. The docs say app/helpers is for: Holds view helpers that should be named like weblog_helper.rb. What does this mean / is it what I''m looking for? I know this is a bit silly, but I''m building something that is to be used as a demonstration of RoR.. and as such I''d like it to follow the community''s conventions. -- Kevin http://kevin.is-a-geek.net _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 27-apr-05, at 21:04, Kevin Davis wrote:> I have some things I''ll be using across multiple controllers (generic > parameter checking / text processing type methods). I''m wondering > where one should put this stuff. > > The docs say app/helpers is for: > Holds view helpers that should be named like weblog_helper.rb. > > What does this mean / is it what I''m looking for? > > I know this is a bit silly, but I''m building something that is to be > used as a demonstration of RoR.. and as such I''d like it to follow the > community''s conventions.Yes, and if it is a helper you will use across all controllers make it an application.rb helper (this way it should get loaded into all pages by default). -- Julian "Julik" Tarkhanov
I think you meant application_helper.rb and not application.rb. application.rb defines ApplicationController, the base class for all of your controllers. application_helper.rb (in app/helpers) defines the ApplicationHelper module which is where you define helper methods for all views in your application. If you need a method to be accessible in controller code across your app, then put it in application.rb (in app/controllers). If you need to access it across all views, put it in application_helper.rb. If you need both, then put it in application.rb and mark it with the helper_method macro. Brian On 4/28/05, Julian ''Julik'' Tarkhanov <listbox-RY+snkucC20@public.gmane.org> wrote:> > On 27-apr-05, at 21:04, Kevin Davis wrote: > > > I have some things I''ll be using across multiple controllers (generic > > parameter checking / text processing type methods). I''m wondering > > where one should put this stuff. > > > > The docs say app/helpers is for: > > Holds view helpers that should be named like weblog_helper.rb. > > > > What does this mean / is it what I''m looking for? > > > > I know this is a bit silly, but I''m building something that is to be > > used as a demonstration of RoR.. and as such I''d like it to follow the > > community''s conventions. > > Yes, and if it is a helper you will use across all controllers make it > an application.rb helper (this way it should get loaded into all pages > by default). > -- > Julian "Julik" Tarkhanov > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- The years ahead pick up their dark bags. They move closer. There''s a slight rise in the silence then nothing. -- (If you''re receiving this in response to mail sent to bluczkie-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org, don''t be concerned This is my new address, but mail will be forwarded here indefinitely)
On 28-apr-05, at 20:34, Brian L. wrote:> I think you meant application_helper.rb and not application.rb. > application.rb defines ApplicationController, the base class for all > of your controllers. application_helper.rb (in app/helpers) defines > the ApplicationHelper module which is where you define helper methods > for all views in your application. If you need a method to be > accessible in controller code across your app, then put it in > application.rb (in app/controllers). If you need to access it across > all views, put it in application_helper.rb. If you need both, then put > it in application.rb and mark it with the helper_method macro. >My fault. I thought it''s "helpers/application.rb". -- Julian "Julik" Tarkhanov