[Rails] How do you define a method

Craig White craigwhite at azapple.com
Thu Aug 10 12:32:07 GMT 2006


On Tue, 2006-08-08 at 21:03 +0200, 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")
> 
> 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..
----
try putting in your model the statement...

require "filename_of_file_that_has_the_needed_method"

Craig



More information about the Rails mailing list