Women in Technology

Hear us Roar



Article:
  Rolling with Ruby on Rails
Subject:   NoMethodError in Recipe#list
Date:   2006-12-11 20:26:59
From:   jshphoto
Response to: NoMethodError in Recipe#list

Also. This is the extracted html error i got


Extracted source (around line #1):


1: <html>
<head>
<title>All Recipes</title>
</head>
<body>


<h1>Online Cookbook - All Recipes</h1>
<table border="1">
<tr>
<td width="40%">

Recipe</td>
<td width="20%">

Category</td>
<td width="20%">

Date</td>
</tr>


<% @recipes.each do |recipe| %>
<tr>
<td><%= link_to recipe.title, :action => "show", :id => recipe.id %></td>
<td><%= recipe.category.name %></td>
<td><%= recipe.date %></td>
</tr>
<% end %>
</table>

<%= link_to "Create new recipe", :action => "new" %>


</body>
</html>


RAILS_ROOT: /Users/jameshouser/Sites/cookbook3/public/../config/..

Full Threads Oldest First

Showing messages 1 through 4 of 4.

  • NoMethodError in Recipe#list
    2007-04-13 19:41:24  RRS2007 [View]

    The reason is you did not put " Autoincrement" for the id column in the recipe table. You can try this sql query below:

    drop table if exists recipes;
    drop table if exists categories;
    create table categories (
    id int not null auto_increment,
    name varchar(100) not null default '',
    primary key(id)
    ) engine=InnoDB;

    create table recipes (
    id int not null auto_increment,
    category_id int not null,
    title varchar(100) not null default '',
    description varchar(255) null,
    date date null,
    instructions text null,
    constraint fk_recipes_categories foreign key (category_id) references categories(id),
    primary key(id)
    ) engine=InnoDB;



    It will create both Recipe and Catagory tables and will drop if you had them previously.

    • NoMethodError in Recipe#list
      2007-04-13 20:08:06  RRS2007 [View]

      Alternatively you can create only the Recipes table:


      create table recipes (
      id int not null auto_increment,
      title varchar(100) not null default '',
      description varchar(255) null,
      date date null,
      instructions text null,
      primary key(id)
      ) engine=InnoDB;
      • NoMethodError in Recipe#list
        2009-04-08 07:32:23  yoberi [View]

        I had a similar error, and it ended up being a typo in the controller code. @params has an 's'... It through me for a loop for quite awhile.

        Regards,
        joshua
      • NoMethodError in Recipe#list
        2009-04-08 07:08:08  yoberi [View]

        I had a similar error, and it ended up being a typo in the controller code. @params has an 's'... It through me for a loop for quite awhile.

        Regards,
        joshua