Shared Helpers -- Newbie Help

2 views
Skip to first unread message

skibud2

unread,
Aug 1, 2007, 5:39:24 PM8/1/07
to Ruby on Rails: Talk
I am trying to make a shared helper. I have searched near and far for
every piece of help, yet I am still stuck. I am assuming it should be
quite easy; I guess just not for me.

# helpers/fun_helper.rb -- Note: this works fine from the
fun_controller
module FunHelper
def test_foo2
"test"
end
end

# test_controller.rb
class TestController < ApplicationController
helper :fun
end

# views/test/index.rhtml
<html>
<body>
<%= test_foo2 %>
</body>
</html>

I am getting the following error:

>> undefined local variable or method `test_foo2' for ...

Thank you,

Mike

jemminger

unread,
Aug 2, 2007, 10:31:36 PM8/2/07
to Ruby on Rails: Talk
if you want it to be available from anywhere, put it in helpers/
application_helper.rb
Reply all
Reply to author
Forward
0 new messages