On Jul 11, 8:58 am, Dheeraj Kumar <a.dheeraj.ku...@gmail.com> wrote: > Helpers help generate code for the view. For example, if you have an array > of items that need to be rendered in a specific way, you can encapsulate > that functionality in a helper method, and call it from the view. It helps > clean up the view code, and adds code reuse. So helpers are meant to be for > views, not controllers. > > On Mon, Jul 11, 2011 at 1:06 PM, Rodrigo Ruiz <rodrigo.ru...@gmail.com>wrote: > > > > > I'd like to know where exactly are helpers available by default? > > > For example, if I have a PagesController, will my PagesHelper methods be > > available at PagesController? or just at the Pages's views?
Dheeraj is correct, helpers are intended for views, but if you have a method that you need access to in your controller and your view, and/ or your helper then, in order to keep things a little DRYer, you can define your method in your controller, and make it available to the view and helper as so: class MyController < ApplicationController helper_method :my_method private def my_method # do something end end Now you can access my_method from your view or your helper as well as your controller. hth Paul > > > Thank you, > > Rodrigo > > > -- > > 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 rubyonrails-talk@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.- Hide quoted text - > > - Show quoted text - -- 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 rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.