About the Authors | p. xv |
About the Technical Reviewer | p. xvii |
Acknowledgments | p. xix |
Preface | p. xxi |
Introduction | p. xxiii |
Introducing the Rails Framework | p. 1 |
The Rise and Rise of the Web Application | p. 1 |
The Web Is Not Perfect | p. 3 |
The Good Web Framework | p. 3 |
Enter Rails | p. 4 |
Rails Is Ruby | p. 5 |
Rails Encourages Agility | p. 6 |
Rails Is Opinionated Software | p. 9 |
Rails Is Open Source | p. 9 |
The MVC Pattern | p. 10 |
The MVC Cycle | p. 11 |
The Layers of MVC | p. 12 |
The Libraries That Make Up Rails | p. 15 |
Rails Is No Silver Bullet | p. 15 |
Summary | p. 16 |
Getting Started | p. 17 |
An Overview of Rails Installation | p. 17 |
Installing on Mac OS X 10.4 Tiger | p. 19 |
Installing the Apple Developer Tools (Xcode) | p. 20 |
Installing MySQL | p. 20 |
Adding MySQL to Your Path | p. 23 |
Installing Ruby | p. 24 |
Installing RubyGems | p. 26 |
Installing Rails | p. 27 |
Automating Installation | p. 27 |
Installing on Windows XP | p. 28 |
Installing MySQL | p. 29 |
Installing Ruby | p. 30 |
Installing Rails | p. 31 |
Installing on Linux | p. 32 |
Installing MySQL | p. 33 |
Installing Ruby | p. 34 |
Installing RubyGems | p. 35 |
Installing Rails | p. 35 |
Creating Your First Rails Application | p. 36 |
Starting the Built-In Web Server | p. 37 |
Generating a Controller | p. 39 |
Creating an Action | p. 40 |
Creating a Template | p. 40 |
Summary | p. 43 |
Getting Something Running | p. 45 |
An Overview of the Project | p. 45 |
Creating the Events Application | p. 46 |
Creating the Project Databases | p. 48 |
Creating the Event Model | p. 50 |
Creating a Database Table | p. 51 |
Generating a Controller | p. 54 |
Up and Running with Scaffolding | p. 54 |
Adding More Fields | p. 57 |
Adding Validations | p. 59 |
Generating a Scaffold | p. 60 |
Summary | p. 63 |
Working with a Database: Active Record | p. 65 |
Introducing Active Record: Object-Relational Mapping on Rails | p. 66 |
What About SQL? | p. 67 |
Active Record Conventions | p. 68 |
Introducing the Console | p. 69 |
Active Record Basics: CRUD | p. 72 |
Creating New Records | p. 72 |
Reading (Finding) Records | p. 77 |
Updating Records | p. 82 |
Deleting Records | p. 83 |
When Good Models Go Bad | p. 85 |
Summary | p. 88 |
Advanced Active Record: Enhancing Your Models | p. 89 |
Adding Methods | p. 89 |
Using Associations | p. 92 |
Declaring Associations | p. 94 |
Creating One-to-One Associations | p. 95 |
Creating One-to-Many Associations | p. 99 |
Applying Association Options | p. 105 |
Creating Many-to-Many Associations | p. 107 |
Creating Rich Many-to-Many Associations | p. 112 |
Building Conditions for Advanced Finding | p. 115 |
Using a Conditions Hash | p. 115 |
Using a SQL Fragment | p. 116 |
Using an Array | p. 117 |
Using Association Proxies | p. 119 |
Applying Validations | p. 120 |
Building Custom Validation Methods | p. 121 |
Using Built-in Validations | p. 122 |
Making Callbacks | p. 125 |
Reviewing the Updated Models | p. 127 |
Updating the User Model | p. 128 |
Summary | p. 132 |
Action Pack: Working with the View and the Controller | p. 133 |
Action Pack Components | p. 133 |
Action Controller | p. 134 |
Action View | p. 137 |
Embedded Ruby | p. 138 |
Helpers | p. 138 |
Routing | p. 139 |
The Action Pack Request Cycle | p. 140 |
A Controller Walk-Through | p. 142 |
Setting Up Routes | p. 142 |
Generating a Controller | p. 146 |
Creating a Template | p. 148 |
Working with Layouts | p. 149 |
Creating a Registration Form | p. 151 |
Using Form Helpers | p. 153 |
Processing Request Parameters | p. 156 |
Writing a Create Action | p. 156 |
Rendering Responses | p. 157 |
Redirecting | p. 158 |
Displaying Error Messages in Templates | p. 158 |
Adding the Edit Form | p. 160 |
Staying Dry with Partials | p. 161 |
Adding the Login and Logout Actions | p. 165 |
Improving the Events Controller and Templates | p. 171 |
Cleaning Up the Events Controller | p. 171 |
Using Partials in the Events Templates | p. 172 |
Adding Categories to the Events Form | p. 173 |
Handling Categories in the Events Controller | p. 175 |
Using Controller Filters | p. 177 |
Requiring Authentication with Filters | p. 178 |
Applying Filters to Controllers | p. 180 |
Adding Finishing Touches | p. 182 |
Using Action View Helpers | p. 182 |
Escaping HTML in Templates | p. 184 |
Formatting a Description Field | p. 185 |
Adding Edit Controls | p. 186 |
Adding Custom Helpers | p. 188 |
Giving It Some Style | p. 189 |
Summary | p. 200 |
Improving Interaction with Ajax | p. 201 |
Ajax and Rails | p. 201 |
Prototype and Helpers | p. 202 |
JavaScript Libraries | p. 202 |
Using Ajax Helpers | p. 203 |
Making Remote Calls with link_to_remote | p. 204 |
Posting Forms Remotely with form_remote_tag | p. 210 |
Polling for Changes with observe_field and observe_form | p. 214 |
Using script.aculo.us Helpers | p. 217 |
Implementing Auto-Completion | p. 217 |
Adding an In-Place Editor | p. 219 |
Adding Visual Effects | p. 222 |
Using RJS Templates | p. 224 |
Implementing RJS in Templates | p. 224 |
Implementing RJS in the Controller | p. 227 |
Summary | p. 228 |
Sending and Receiving Mail | p. 229 |
Setting Up Action Mailer | p. 229 |
Configuring Mail Server Settings | p. 230 |
Configuring Application Settings | p. 231 |
Sending Email | p. 232 |
Handling Basic Email | p. 234 |
Sending HTML Email | p. 237 |
Adding Multiple Parts to Messages | p. 239 |
Adding Attachments | p. 240 |
Sending Incoming Email to a Rails Process | p. 241 |
Summary | p. 243 |
Testing Your Application | p. 245 |
How Rails Handles Testing | p. 246 |
Unit Testing Your Rails Application | p. 247 |
Testing the Event Model | p. 249 |
Testing Validations | p. 255 |
Functional Testing Your Controllers | p. 256 |
Testing the Events Controller | p. 256 |
Creating a Test Helper | p. 258 |
Running the Functional Test Suite | p. 264 |
Integration Testing | p. 267 |
Integration Testing the Events Application | p. 268 |
Story-Based Testing | p. 271 |
Running the Full Test Suite | p. 275 |
Measuring Test Coverage with Rcov | p. 276 |
Summary | p. 278 |
Extending Rails with Plugins | p. 279 |
Finding and Installing Plugins | p. 279 |
Finding Plugins | p. 280 |
Installing Plugins | p. 281 |
Using a Plugin in Our Application | p. 282 |
Modifying the Database | p. 282 |
Modifying the Application to Use the Plugin | p. 283 |
Creating Your Own Plugin | p. 287 |
Making the Plugin Available to Applications | p. 288 |
Creating the Plugin Module | p. 289 |
Updating the Controller and Views | p. 297 |
Summary | p. 300 |
Deploying Your Rails Applications | p. 301 |
Deploying with Capistrano | p. 301 |
Capistrano Installation | p. 302 |
Capistrano Recipes | p. 305 |
Capistrano on the Deployment Server | p. 307 |
Custom Capistrano Tasks | p. 308 |
Setting Up Your Server Architecture | p. 308 |
Monolithic Architecture | p. 308 |
Proxy-Cluster Server: The New Kid on the Block | p. 309 |
Becoming an Instant Deployment Expert | p. 311 |
Summary | p. 312 |
Ruby, a Programmer's Best Friend | p. 315 |
Instant Interaction | p. 315 |
Ruby Types | p. 316 |
Strings | p. 316 |
Numbers | p. 318 |
Symbols | p. 318 |
Arrays and Hashes | p. 319 |
Language Basics | p. 320 |
Variables | p. 320 |
Operators | p. 322 |
Blocks and Iterators | p. 322 |
Control Structures | p. 323 |
Methods | p. 325 |
Classes and Objects | p. 326 |
Objects | p. 326 |
Classes | p. 327 |
Ruby Documentation | p. 330 |
Databases 101 | p. 331 |
Examining a Database Table | p. 331 |
Working with Tables | p. 332 |
Selecting Data | p. 333 |
Inserting Data | p. 335 |
Updating Data | p. 335 |
Deleting Data | p. 336 |
Understanding Relationships | p. 337 |
SQL and Active Record | p. 340 |
The Rails Community | p. 341 |
Rails Mailing Lists | p. 341 |
Rails IRC Channel | p. 341 |
Rails Blogs and Podcast | p. 342 |
Rails Wiki | p. 343 |
Rails APIs | p. 343 |
Rails Trac | p. 344 |
Working with Rails Directory | p. 344 |
Index | p. 345 |
Table of Contents provided by Ingram. All Rights Reserved. |