Undefined?

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

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

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