Hi,
I always get the following error when trying to access a helper method.
--> undefined method `some_helper_method'' for
#<BlogController:0x2706fec>
blog_controller.rb:
class BlogController < ApplicationController
def index
render(:text => some_helper_method("x"))
end
end
blog_helper.rb:
module BlogHelper
def some_helper_method(text)
text+="!!!!"
end
end
(Structure came from script/generate controller Blog)
On a sidebar ... What I was actually trying is to use textilize, but also
got the same error message. Installing redcloth as gem didn''t help,
neither
adding require_gem "RedCloth" to environment.rb.
???
Any idea what I do wrong?
Cheers,
Mariano
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
> blog_controller.rb: > class BlogController < ApplicationController > def index > render(:text => some_helper_method("x")) > end > endHelpers are not available in controllers. Try this instead: def index render :inline => "<%= some_helper_method(''x'') %>" end -- rick http://techno-weenie.net
Rick Olson wrote:>>blog_controller.rb: >>class BlogController < ApplicationController >> def index >> render(:text => some_helper_method("x")) >> end >>end >> >> > >Helpers are not available in controllers. Try this instead: > >def index > render :inline => "<%= some_helper_method(''x'') %>" >end > >Another possibility is: def index render_text(@template.some_helper_method("x")) end More efficient too. But it will not work for helpers that require the full view context to run. -- stefan http://railsexpress.de/blog