Women in Technology

Hear us Roar



Article:
  Rolling with Ruby on Rails Revisited
Subject:   is the code complete ?
Date:   2006-12-20 12:10:44
From:   sbaptista
Response to: is the code complete ?

> When trying to enter a recipe it fails because foreign key is absent. It is not an option on the [web] page.


I've got the same problem. If you notice, the article screenshot for a new recipe ("Figure 11 new recipe entry page") on page 2 also does not offer a way to select a category.


Presumably, the code generator is supposed to detect the contraint and display something in the UI??


Some notes:


MySQL version: 5.0.27.


I used the following script to generate the database:



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;



Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • is the code complete ?
    2007-10-18 11:17:56  miwi1142 [View]

    When I go to http://localhost:3000/recipe
    and click on create, and fill out the form,
    the submit does not go through because category_id is not being preset. In fact category does not show up in the recipe screen, just like in your screenshot. How can I fix that?

    Mysql::Error: #23000Column 'category_id' cannot be null: INSERT INTO recipes (`title`, `date`, `category_id`, `description`, `instructions`) VALUES('afdsfa', '2007-10-18', NULL, 'dfsafas', 'dfsafsafdsa')

    • is the code complete ?
      2007-10-21 12:27:08  Bill Walton | [View]

      Hi,

      You're definitely not the first to ask the question ;-) The answer can be found in the second paragraph of my response just above, dated 2006-12-20.

      Best regards,
      Bill