Preface to the Second Edition |
|
xiii | |
Preface to the Third Edition |
|
xv | |
1 Introduction |
|
1 | |
|
|
3 | |
|
1.2 Finding Your Way Around |
|
|
4 | |
|
|
6 | |
Part I Getting Started |
|
9 | |
|
2 The Architecture of Rails Applications |
|
|
11 | |
|
2.1 Models, Views, and Controllers |
|
|
11 | |
|
2.2 Active Record: Rails Model Support |
|
|
14 | |
|
2.3 Action Pack: The View and Controller |
|
|
18 | |
|
|
21 | |
|
|
21 | |
|
3.2 Installing on Windows |
|
|
21 | |
|
3.3 Installing on Mac OS X |
|
|
23 | |
|
|
24 | |
|
3.5 Choosing a Rails Version |
|
|
26 | |
|
3.6 Development Environments |
|
|
26 | |
|
|
30 | |
|
|
32 | |
|
|
32 | |
|
|
35 | |
|
4.1 Creating a New Application |
|
|
35 | |
|
|
37 | |
|
4.3 Linking Pages Together |
|
|
48 | |
|
|
52 | |
Part II Building an Application |
|
53 | |
|
|
55 | |
|
5.1 Incremental Development |
|
|
55 | |
|
|
56 | |
|
|
60 | |
|
6 Task A: Product Maintenance |
|
|
61 | |
|
6.1 Iteration Al: Getting Something Running |
|
|
61 | |
|
6.2 Creating the Products Model and Maintenance Application |
|
|
67 | |
|
6.3 Iteration A2: Adding a Missing Column |
|
|
71 | |
|
6.4 Iteration A3: Validating! |
|
|
77 | |
|
6.5 Iteration A4: Making Prettier Listings |
|
|
81 | |
|
7 Task B: Catalog Display |
|
|
87 | |
|
7.1 Iteration B1: Creating the Catalog Listing |
|
|
87 | |
|
7.2 Iteration B2: Adding a Page Layout |
|
|
91 | |
|
7.3 Iteration B3: Using a Helper to Format the Price |
|
|
93 | |
|
7.4 Iteration B4: Linking to the Cart |
|
|
94 | |
|
|
97 | |
|
|
97 | |
|
8.2 Iteration C1: Creating a Cart |
|
|
101 | |
|
8.3 Iteration C2: Creating a Smarter Cart |
|
|
104 | |
|
8.4 Iteration C3: Handling Errors |
|
|
107 | |
|
8.5 Iteration C4: Finishing the Cart |
|
|
112 | |
|
9 Task D: Add a Dash of Ajax |
|
|
117 | |
|
9.1 Iteration D1: Moving the Cart |
|
|
118 | |
|
9.2 Iteration D2: Creating an Ajax-Based Cart |
|
|
123 | |
|
9.3 Iteration D3: Highlighting Changes |
|
|
126 | |
|
9.4 Iteration D4: Hiding an Empty Cart |
|
|
129 | |
|
9.5 Iteration D5: Degrading If Javascript Is Disabled |
|
|
132 | |
|
|
133 | |
|
|
135 | |
|
10.1 Iteration El: Capturing an Order |
|
|
135 | |
|
11 Task F: Administration |
|
|
153 | |
|
11.1 Iteration Fl: Adding Users |
|
|
153 | |
|
11.2 Iteration F2: Logging In |
|
|
162 | |
|
11.3 Iteration F3: Limiting Access |
|
|
165 | |
|
11.4 Iteration F4: Adding a Sidebar, More Administration |
|
|
168 | |
|
12 Task G: One Last Wafer-Thin Change |
|
|
175 | |
|
12.1 Generating the XML Feed |
|
|
175 | |
|
|
185 | |
|
13 Task I: Internationalization |
|
|
187 | |
|
13.1 Iteration Il: Enabling Translation |
|
|
187 | |
|
13.2 Iteration 12: Exploring Strategies for Content |
|
|
201 | |
|
|
205 | |
|
14.1 Tests Baked Right In |
|
|
205 | |
|
14.2 Unit Testing of Models |
|
|
206 | |
|
14.3 Functional Testing of Controllers |
|
|
219 | |
|
14.4 Integration Testing of Applications |
|
|
235 | |
|
|
244 | |
|
|
248 | |
Part III Working with the Rails Framework |
|
251 | |
|
|
253 | |
|
|
253 | |
|
|
253 | |
|
|
260 | |
|
|
264 | |
|
|
268 | |
|
|
268 | |
|
|
270 | |
|
|
271 | |
|
16.1 Generally Available Extensions |
|
|
271 | |
|
16.2 Enumerations and Arrays |
|
|
272 | |
|
|
274 | |
|
|
274 | |
|
16.5 Extensions to Numbers |
|
|
277 | |
|
16.6 Time and Date Extensions |
|
|
278 | |
|
16.7 An Extension to Ruby Symbols |
|
|
280 | |
|
|
280 | |
|
|
281 | |
|
|
287 | |
|
17.1 Creating and Running Migrations |
|
|
289 | |
|
17.2 Anatomy of a Migration |
|
|
291 | |
|
|
295 | |
|
|
300 | |
|
|
303 | |
|
17.6 When Migrations Go Bad |
|
|
307 | |
|
17.7 Schema Manipulation Outside Migrations |
|
|
308 | |
|
|
309 | |
|
18 Active Record: The Basics |
|
|
311 | |
|
|
312 | |
|
18.2 Columns and Attributes |
|
|
312 | |
|
18.3 Primary Keys and ids |
|
|
316 | |
|
18.4 Connecting to the Database |
|
|
318 | |
|
18.5 Create, Read, Update, Delete (CRUD) |
|
|
323 | |
|
18.6 Aggregation and Structured Data |
|
|
342 | |
|
|
349 | |
|
19 Active Record: Relationships Between Tables |
|
|
353 | |
|
19.1 Creating Foreign Keys |
|
|
354 | |
|
19.2 Specifying Relationships in Models |
|
|
356 | |
|
19.3 belongs_to and has_xxx Declarations |
|
|
358 | |
|
19.4 Joining to Multiple Tables |
|
|
373 | |
|
19.5 Self-referential Joins |
|
|
383 | |
|
|
384 | |
|
19.7 When Things Get Saved |
|
|
388 | |
|
19.8 Preloading Child Rows |
|
|
390 | |
|
|
391 | |
|
20 Active Record: Object Life Cycle |
|
|
393 | |
|
|
393 | |
|
|
403 | |
|
|
410 | |
|
|
414 | |
|
21 Action Controller: Routing and URLs |
|
|
421 | |
|
|
421 | |
|
|
422 | |
|
21.3 Resource-Based Routing |
|
|
437 | |
|
|
454 | |
|
22 Action Controller and Rails |
|
|
457 | |
|
|
457 | |
|
22.2 Cookies and Sessions |
|
|
469 | |
|
22.3 Flash: Communicating Between Actions |
|
|
482 | |
|
22.4 Filters and Verification |
|
|
484 | |
|
|
492 | |
|
22.6 The Problem with GET Requests |
|
|
501 | |
|
|
505 | |
|
|
505 | |
|
|
511 | |
|
23.3 Helpers for Formatting, Linking, and Pagination |
|
|
512 | |
|
|
520 | |
|
23.5 Forms That Wrap Model Objects |
|
|
521 | |
|
23.6 Custom Form Builders |
|
|
534 | |
|
23.7 Working with Nonmodel Fields |
|
|
538 | |
|
23.8 Uploading Files to Rails Applications |
|
|
541 | |
|
23.9 Layouts and Components |
|
|
545 | |
|
|
552 | |
|
23.11 Adding New Templating Systems |
|
|
557 | |
|
|
561 | |
|
|
561 | |
|
|
581 | |
|
|
598 | |
|
|
605 | |
|
|
607 | |
|
|
607 | |
|
|
618 | |
|
|
620 | |
|
|
623 | |
|
26.1 Alternatives to Active Resource |
|
|
623 | |
|
|
626 | |
|
26.3 Relationships and Collections |
|
|
629 | |
|
26.4 Pulling It All Together |
|
|
632 | |
Part IV Securing and Deploying Your Application |
|
635 | |
|
27 Securing Your Rails Application |
|
|
637 | |
|
|
637 | |
|
27.2 Creating Records Directly from Form Parameters |
|
|
640 | |
|
27.3 Don't Trust id Parameters |
|
|
641 | |
|
27.4 Don't Expose Controller Methods |
|
|
642 | |
|
27.5 Cross-Site Scripting (CSS/XSS) |
|
|
643 | |
|
27.6 Avoid Session Fixation Attacks |
|
|
646 | |
|
|
646 | |
|
27.8 Don't Store Sensitive Information in the Clear |
|
|
647 | |
|
27.9 Use SSL to Transmit Sensitive Information |
|
|
648 | |
|
27.10 Don't Cache Authenticated Pages |
|
|
650 | |
|
27.11 Knowing That It Works |
|
|
650 | |
|
28 Deployment and Production |
|
|
651 | |
|
|
651 | |
|
28.2 How a Production Server Works |
|
|
652 | |
|
28.3 Installing Passenger |
|
|
655 | |
|
28.4 Worry-Free Deployment with Capistrano |
|
|
657 | |
|
28.5 Checking Up on a Deployed Application |
|
|
661 | |
|
28.6 Production Application Chores |
|
|
662 | |
|
28.7 Moving On to Launch and Beyond |
|
|
664 | |
Part V Appendixes |
|
665 | |
|
|
667 | |
|
A.1 Ruby Is an Object-Oriented Language |
|
|
667 | |
|
|
668 | |
|
|
669 | |
|
|
671 | |
|
|
673 | |
|
|
674 | |
|
|
675 | |
|
|
676 | |
|
|
676 | |
|
|
677 | |
|
|
678 | |
|
|
678 | |
|
|
678 | |
|
|
680 | |
|
B Configuration Parameters |
|
|
681 | |
|
B.1 Top-Level Configuration |
|
|
681 | |
|
B.2 Active Record Configuration |
|
|
683 | |
|
B.3 Action Controller Configuration |
|
|
685 | |
|
B.4 Action View Configuration |
|
|
687 | |
|
B.5 Action Mailer Configuration |
|
|
687 | |
|
B.6 Test Case Configuration |
|
|
689 | |
|
|
691 | |
|
C.1 The Full Depot Application |
|
|
691 | |
|
|
729 | |
|
|
729 | |
Index |
|
731 | |