I’ve finally gotten to the point where I want to write my own helper
function to call from my views. I used the script/generate to create my
Controller so I also got the helper file.
I defined the method I wanted to use in the helper rb file, but when I
try to call them from the view I get a NoMethodError raised.
Is there anything else I have to do besides creating the method in the
Helper module in the app/helpers directory and call it from a view? The
on-line documentation on helpers seems a bit light.
Thanks
Dave
Which file are you putting the helper function into? You might want to
include
*The file that the helper method is in
*The line that calls the method in the view
*The error that you are getting as a result
In your error report, it’s a bit hard to troubleshoot without more data.
Helper functions work for me. You can try and put your method in
application_helper.rb. Make sure you are not putting your def into the
controller application.rb.
Hi –
On Sun, 13 Aug 2006, Dave Fox wrote:
I’ve finally gotten to the point where I want to write my own helper
function to call from my views. I used the script/generate to create my
Controller so I also got the helper file.
I defined the method I wanted to use in the helper rb file, but when I
try to call them from the view I get a NoMethodError raised.
Is there anything else I have to do besides creating the method in the
Helper module in the app/helpers directory and call it from a view? The
on-line documentation on helpers seems a bit light.
Make sure you define the method inside the module definition:
module SomeHelper
def help_me
…
end
end
and not before or after it. I’m just guessing that might be the
problem – it’s a not unheard-of cause of that NoMethodError from
helpers.
David
–
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack’s][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.