Prev: kramdown 0.1.0 - first relase of fast, pure Ruby Markdownparser
Next: What's the new hotness for packaging gems?
From: T_P on 28 Nov 2009 12:27 Hello! I am new to ruby (and to ruby on rails). Having created some helpers with script/generate helper HelperName how do I access them in controllers and views? :-/ Tuo Pe
From: David Masover on 28 Nov 2009 12:48 On Saturday 28 November 2009 11:30:06 am T_P wrote: > Having created some helpers > with > script/generate helper HelperName > > how do I access them in controllers and views? :-/ Probably, include them into the controller you need, or into ApplicationController to make them available everywhere. But I don't know, haven't touched Rails in awhile. Ask the Rails list.
From: Evan Worley on 29 Nov 2009 05:26 [Note: parts of this message were removed to make it a legal post.] You can specify "helper :all" in ApplicationController.rb, which will make all helpers available to all controllers and views. http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000490 -Evan On Sat, Nov 28, 2009 at 9:48 AM, David Masover <ninja(a)slaphack.com> wrote: > On Saturday 28 November 2009 11:30:06 am T_P wrote: > > Having created some helpers > > with > > script/generate helper HelperName > > > > how do I access them in controllers and views? :-/ > > Probably, include them into the controller you need, or into > ApplicationController to make them available everywhere. > > But I don't know, haven't touched Rails in awhile. Ask the Rails list. > >
From: Brian Candler on 29 Nov 2009 05:53
T_P wrote: > how do I access them in controllers and views? :-/ They are available in views already. For a method to be available both in controllers and views, define it as a method in the ApplicationController instead: private def my_helper(foo) return "#{foo}!!" end helper_method :my_helper -- Posted via http://www.ruby-forum.com/. |