http://www.pragmaticprogrammer.com
Copyrightc2006ThePragmaticProgrammersLLC.
All rights reserved.
Nopart of thispublicationmaybe reproduced, storedina retrieval system,ortransmitted,in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the priorconsent of thepublisher.
Printedin theUnitedStates ofAmerica.
ISBN-10:0-9776166-3-0 ISBN-13:978-0-9776166-3-3 Printed on acid-free paper with85% recycled, 30%post-consumer content. P1.00printing,November22,2006 Version:2006-11-22
Prepared exclusively for Jordan A. Fowler
Contents
Preface to the Second Edition 12
1 Introduction 14
1.1 RailsIsAgile ............................. 16
1.2 FindingYourWayAround ..................... 17
1.3 Acknowledgments .......................... 19
Part I.Getting Started 21
2 The Architecture of Rails Applications 22
2.1 Models,Views,andControllers .................. 22
2.2 ActiveRecord:RailsModelSupport . . . . . . . . . . . . . . . . 25
2.3 ActionPack:TheViewandController . . . . . . . . . . . . . . 29
3 Installing Rails 31
3.1 YourShoppingList ......................... 31
3.2 InstallingonWindows ........................ 32
3.3 InstallingonMacOSX ....................... 34
3.4 InstallingonLinux .......................... 35
3.5 DevelopmentEnvironments .................... 36
3.6 RailsandDatabases......................... 39
3.7 KeepingUp-to-Date ......................... 42
3.8 RailsandISPs ............................ 42
4 Instant Grati.cation 43
4.1 Creating aNewApplication ..................... 43
4.2 Hello,Rails! .............................. 45
4.3 LinkingPagesTogether ....................... 56
4.4 WhatWeJustDid .......................... 59
Prepared exclusively for Jordan A. Fowler
CONTENTS
Part II.Building an Application 61
5 The Depot Application 62
5.1 IncrementalDevelopment ..................... 62
5.2 WhatDepotDoes .......................... 63
5.3 Let�fsCode ............................... 67
6 Task A: Product Maintenance 68
6.1 IterationA1:GetSomethingRunning . . . . . . . . . . . . . . 68
6.2 IterationA2:Add aMissingColumn . . . . . . . . . . . . . . . 79
6.3 IterationA3:Validate! ........................ 81
6.4 IterationA4:PrettierListings ................... 85
7 Task B: Catalog Display 94
7.1 IterationB1:CreatetheCatalogListing . . . . . . . . . . . . . 94
Agile Web Development with Rails
Start from the beginning
