From: Brian Candler Date: 2007-03-19T05:56:24+09:00 Subject: Re: accessing methods from the blocks caller On Mon, Mar 19, 2007 at 05:40:45AM +0900, Brian Candler wrote: > This is a rails issue. The *controller* and the *view* are two separate > objects; methods defined in the controller are not by default available in > the view. > > The preferred solution is usually to define render_to_string as a helper in > app/helpers/mys.rb (as long as it's needed only by the view, not by the > controller itself) > > If you must define it in the controller for some reason, then you can make > it available in the view by > > def render_to_string > ... > end > helper_method :render_to_string Alternatively: I think that *public* methods in the controller can be accessed from within the view by using the 'controller' accessor. e.g. <%= controller.render_to_string %> But this is probably not a good idea if render_to_string is a method which you don't want to make available to the outside world (in which case you should mark it 'private') B.