[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rails: helper methods not found

ritchie

4/14/2005 12:32:00 AM

hi there

I'm trying to use helpers in my controller, but they're not turning up.

NoMethodError in Switcher#index

undefined method `create_menu' for SwitcherController:Class

app/controllers/switcher_controller.rb:7:in `index'
script/server:48

I'm doing this at the top of my class

class SwitcherController < ApplicationController

helper :switcher

....

end

and the helper switcher_helper.rb exists in the helper dir

module SwitcherHelper

def create_menu(dir)
$menu = {}
menu_level(dir)
end

....

end

thanks for showing me the error of my ways ... also it is loading
switcher_helper.rb, cos if I add an exit at the top of the file it lets
me know.

ritchie

2 Answers

David Heinemeier Hansson

4/14/2005 11:29:00 AM

0

> I'm trying to use helpers in my controller, but they're not turning up.
>
> NoMethodError in Switcher#index

Helpers are _view_ helpers. The controller doesn't have access to the
methods defined in the helpers. Also, since you're following the
default naming convention, you don't need to be explicit with "helper
:switcher". That'll happen automatically.
--
David Heinemeier Hansson,
http://www.basec... -- Web-based Project Management
http://www.rubyon... -- Web-application framework for Ruby
http://www.loudthi... -- Broadcasting Brain



ritchie

4/14/2005 12:58:00 PM

0

ok, thanks david.