Forum: Ruby on Rails undefined??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Simon (Guest)
on 2006-05-11 13:22
When following the ONrails "Rolling on Ruby with Rails" tutorial part1 I
(already) encountered the first complication.

After doing those basic actions to set up the basic site, the tutorial
tells me to overwrite the "list" method included in the "scaffold
:recipe" method which we find in the recipe controller with this code:

def list
  @recipes = recipe.find_all
end

Now this code doesn't work. When trying to view my site I keep getting
an error message which says that the variable recipe is undefined.
With the (average) knowledge I own concerning programming I suppose
"@recipes" should define the variable, which doesn't happen here.

I searched half rubyonrails.org looking for another way of defining that
variable, but it's alway "@recipe". I followed every step in that
tutorial closely, does anyone know what's wrong? I use Ruby version
182-14.


thx in advance
Stephen B. (Guest)
on 2006-05-11 13:49
(Received via mailing list)
Hi,

You don't need to define variables in Ruby.

The problem is likely to be the case of the class you're calling.  The
line should read:

@recipes = Recipe.find_all

Hope that helps,

Steve
Matthew P. (Guest)
on 2006-05-11 22:40
(Received via mailing list)
On Thu, May 11, 2006 at 11:22:32AM +0200, Simon wrote:
>
> Now this code doesn't work. When trying to view my site I keep getting
> an error message which says that the variable recipe is undefined.
> With the (average) knowledge I own concerning programming I suppose
> "@recipes" should define the variable, which doesn't happen here.

I suspect that you want Recipe.find_all, not recipe.find_all.

- Matt
This topic is locked and can not be replied to.