Hi, i`m new to ruby and rails ,so here is a newbie question. I want to use my helpers from the views in my controllers but can`t get them included. How should I do this ? Thanks Oliver _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Oliver Dohmen wrote:> I want to use my helpers from the views in my controllers but can`t > get them included. > How should I do this ?It''s the other way around. You define the method in your controller (or application.rb), then use helper_method() to make it available as a helper in the views. Eg: class ApplicationController < ActionController::Base def say_hello(name) "hello #{name}" end helper_method :say_hello end Enjoy! --- Justin French, Indent.com.au justin.french-zULN+VWqVOIpAS55Wn97og@public.gmane.org Web Application Development & Graphic Design
Am 02.09.2005 um 15:57 schrieb Justin French:> Oliver Dohmen wrote: > > >> I want to use my helpers from the views in my controllers but >> can`t get them included. >> How should I do this ? >> > > It''s the other way around. You define the method in your > controller (or application.rb), then use helper_method() to make it > available as a helper in the views. > > Eg: > > class ApplicationController < ActionController::Base > def say_hello(name) > "hello #{name}" > end > helper_method :say_hello > end > > Enjoy! >Thanks, I will try it. And move my stuff in the controller. Oliver Dohmen odo-5ZfecQFW2BIjEVVQ2C+MCw@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails