How do you define a method

Hi all,
I was wondering if anybody could help me figure why a view cannot find a
method that I defined in another class. I do this in the view: (let’s
say index.rhtml)

<%= check_box(“item_search_page”, “method_name”)

Here, item_search_page is a variable in the view’s controller, which
creates a new ItemSearchPage object. And I defined “method_name” in the
class:

class ItemSearchPage
def method_name
end
end

So, although I defined the method and it’s public, the view says
"undefined method ‘method_name’.

Thanks for your help…

Victor Al wrote:

Hi all,
I was wondering if anybody could help me figure why a view cannot find a
method that I defined in another class. I do this in the view: (let’s
say index.rhtml)

<%= check_box(“item_search_page”, “method_name”)

Off the top of my head, I think this will attempt do get the value from
the following call within the controller:

@item_search_page.method_name

APIs here:
http://rubyonrails.org/api/classes/ActionView/Helpers/FormHelper.html

On Tue, 2006-08-08 at 21:03 +0200, Victor Al wrote:

class ItemSearchPage
def method_name
end
end

So, although I defined the method and it’s public, the view says
"undefined method ‘method_name’.

Thanks for your help…


try putting in your model the statement…

require “filename_of_file_that_has_the_needed_method”

Craig

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs