| Sign In/My Account | View Cart |
| Article: |
Rolling with Ruby on Rails Revisited | |
| Subject: | is the code complete ? | |
| Date: | 2006-12-17 15:30:55 | |
| From: | will_macdonald | |
|
I just followed all the example using Locomotive.
|
||
Showing messages 1 through 10 of 10.
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;
I just realized that when we cut the tutorial into Part 1 and Part 2 we should have put a note telling the reader that, in fact, the recipe creation will not work at that point. It will fail for exactly the reason you're seeing. We told MySQL that there would be a foreign key. We haven't told Rails about it though. And we can't create a recipe until we do. That comes next. Sorry guys. You're going to have to wait for the second installment. Or...
If you just can't wait to enter a recipe, just take the foreign key constraint (and the field) out of the script.
Again, my apologies. The tutorial was written and reviewed as one (long) work. When we chopped it into two pieces for publication, we obviously didn't cut cleanly. Lesson learned.
Best regards and best wishes for a safe and happy holiday,
Bill