Following the excellent Rails Tutorials, although where things go wrong it's all my doing.