| |
| |
About the Authors | |
| |
| |
About the Technical Reviewer | |
| |
| |
Acknowledgments | |
| |
| |
Preface | |
| |
| |
Introduction | |
| |
| |
| |
Introducing the Rails Framework | |
| |
| |
The Rise and Rise of the Web Application | |
| |
| |
The Web Is Not Perfect | |
| |
| |
The Good Web Framework | |
| |
| |
Enter Rails | |
| |
| |
Rails Is Ruby | |
| |
| |
Rails Encourages Agility | |
| |
| |
Rails Is Opinionated Software | |
| |
| |
Rails Is Open Source | |
| |
| |
The MVC Pattern | |
| |
| |
The MVC Cycle | |
| |
| |
The Layers of MVC | |
| |
| |
The Libraries That Make Up Rails | |
| |
| |
Rails Is No Silver Bullet | |
| |
| |
Summary | |
| |
| |
| |
Getting Started | |
| |
| |
An Overview of Rails Installation | |
| |
| |
Installing on Mac OS X 10.4 Tiger | |
| |
| |
Installing the Apple Developer Tools (Xcode) | |
| |
| |
Installing MySQL | |
| |
| |
Adding MySQL to Your Path | |
| |
| |
Installing Ruby | |
| |
| |
Installing RubyGems | |
| |
| |
Installing Rails | |
| |
| |
Automating Installation | |
| |
| |
Installing on Windows XP | |
| |
| |
Installing MySQL | |
| |
| |
Installing Ruby | |
| |
| |
Installing Rails | |
| |
| |
Installing on Linux | |
| |
| |
Installing MySQL | |
| |
| |
Installing Ruby | |
| |
| |
Installing RubyGems | |
| |
| |
Installing Rails | |
| |
| |
Creating Your First Rails Application | |
| |
| |
Starting the Built-In Web Server | |
| |
| |
Generating a Controller | |
| |
| |
Creating an Action | |
| |
| |
Creating a Template | |
| |
| |
Summary | |
| |
| |
| |
Getting Something Running | |
| |
| |
An Overview of the Project | |
| |
| |
Creating the Events Application | |
| |
| |
Creating the Project Databases | |
| |
| |
Creating the Event Model | |
| |
| |
Creating a Database Table | |
| |
| |
Generating a Controller | |
| |
| |
Up and Running with Scaffolding | |
| |
| |
Adding More Fields | |
| |
| |
Adding Validations | |
| |
| |
Generating a Scaffold | |
| |
| |
Summary | |
| |
| |
| |
Working with a Database: Active Record | |
| |
| |
Introducing Active Record: Object-Relational Mapping on Rails | |
| |
| |
What About SQL? | |
| |
| |
Active Record Conventions | |
| |
| |
Introducing the Console | |
| |
| |
Active Record Basics: CRUD | |
| |
| |
Creating New Records | |
| |
| |
Reading (Finding) Records | |
| |
| |
Updating Records | |
| |
| |
Deleting Records | |
| |
| |
When Good Models Go Bad | |
| |
| |
Summary | |
| |
| |
| |
Advanced Active Record: Enhancing Your Models | |
| |
| |
Adding Methods | |
| |
| |
Using Associations | |
| |
| |
Declaring Associations | |
| |
| |
Creating One-to-One Associations | |
| |
| |
Creating One-to-Many Associations | |
| |
| |
Applying Association Options | |
| |
| |
Creating Many-to-Many Associations | |
| |
| |
Creating Rich Many-to-Many Associations | |
| |
| |
Building Conditions for Advanced Finding | |
| |
| |
Using a Conditions Hash | |
| |
| |
Using a SQL Fragment | |
| |
| |
Using an Array | |
| |
| |
Using Association Proxies | |
| |
| |
Applying Validations | |
| |
| |
Building Custom Validation Methods | |
| |
| |
Using Built-in Validations | |
| |
| |
Making Callbacks | |
| |
| |
Reviewing the Updated Models | |
| |
| |
Updating the User Model | |
| |
| |
Summary | |
| |
| |
| |
Action Pack: Working with the View and the Controller | |
| |
| |
Action Pack Components | |
| |
| |
Action Controller | |
| |
| |
Action View | |
| |
| |
Embedded Ruby | |
| |
| |
Helpers | |
| |
| |
Routing | |
| |
| |
The Action Pack Request Cycle | |
| |
| |
A Controller Walk-Through | |
| |
| |
Setting Up Routes | |
| |
| |
Generating a Controller | |
| |
| |
Creating a Template | |
| |
| |
Working with Layouts | |
| |
| |
Creating a Registration Form | |
| |
| |
Using Form Helpers | |
| |
| |
Processing Request Parameters | |
| |
| |
Writing a Create Action | |
| |
| |
Rendering Responses | |
| |
| |
Redirecting | |
| |
| |
Displaying Error Messages in Templates | |
| |
| |
Adding the Edit Form | |
| |
| |
Staying Dry with Partials | |
| |
| |
Adding the Login and Logout Actions | |
| |
| |
Improving the Events Controller and Templates | |
| |
| |
Cleaning Up the Events Controller | |
| |
| |
Using Partials in the Events Templates | |
| |
| |
Adding Categories to the Events Form | |
| |
| |
Handling Categories in the Events Controller | |
| |
| |
Using Controller Filters | |
| |
| |
Requiring Authentication with Filters | |
| |
| |
Applying Filters to Controllers | |
| |
| |
Adding Finishing Touches | |
| |
| |
Using Action View Helpers | |
| |
| |
Escaping HTML in Templates | |
| |
| |
Formatting a Description Field | |
| |
| |
Adding Edit Controls | |
| |
| |
Adding Custom Helpers | |
| |
| |
Giving It Some Style | |
| |
| |
Summary | |
| |
| |
| |
Improving Interaction with Ajax | |
| |
| |
Ajax and Rails | |
| |
| |
Prototype and Helpers | |
| |
| |
JavaScript Libraries | |
| |
| |
Using Ajax Helpers | |
| |
| |
Making Remote Calls with link_to_remote | |
| |
| |
Posting Forms Remotely with form_remote_tag | |
| |
| |
Polling for Changes with observe_field and observe_form | |
| |
| |
Using script.aculo.us Helpers | |
| |
| |
Implementing Auto-Completion | |
| |
| |
Adding an In-Place Editor | |
| |
| |
Adding Visual Effects | |
| |
| |
Using RJS Templates | |
| |
| |
Implementing RJS in Templates | |
| |
| |
Implementing RJS in the Controller | |
| |
| |
Summary | |
| |
| |
| |
Sending and Receiving Mail | |
| |
| |
Setting Up Action Mailer | |
| |
| |
Configuring Mail Server Settings | |
| |
| |
Configuring Application Settings | |
| |
| |
Sending Email | |
| |
| |
Handling Basic Email | |
| |
| |
Sending HTML Email | |
| |
| |
Adding Multiple Parts to Messages | |
| |
| |
Adding Attachments | |
| |
| |
Sending Incoming Email to a Rails Process | |
| |
| |
Summary | |
| |
| |
| |
Testing Your Application | |
| |
| |
How Rails Handles Testing | |
| |
| |
Unit Testing Your Rails Application | |
| |
| |
Testing the Event Model | |
| |
| |
Testing Validations | |
| |
| |
Functional Testing Your Controllers | |
| |
| |
Testing the Events Controller | |
| |
| |
Creating a Test Helper | |
| |
| |
Running the Functional Test Suite | |
| |
| |
Integration Testing | |
| |
| |
Integration Testing the Events Application | |
| |
| |
Story-Based Testing | |
| |
| |
Running the Full Test Suite | |
| |
| |
Measuring Test Coverage with Rcov | |
| |
| |
Summary | |
| |
| |
| |
Extending Rails with Plugins | |
| |
| |
Finding and Installing Plugins | |
| |
| |
Finding Plugins | |
| |
| |
Installing Plugins | |
| |
| |
Using a Plugin in Our Application | |
| |
| |
Modifying the Database | |
| |
| |
Modifying the Application to Use the Plugin | |
| |
| |
Creating Your Own Plugin | |
| |
| |
Making the Plugin Available to Applications | |
| |
| |
Creating the Plugin Module | |
| |
| |
Updating the Controller and Views | |
| |
| |
Summary | |
| |
| |
| |
Deploying Your Rails Applications | |
| |
| |
Deploying with Capistrano | |
| |
| |
Capistrano Installation | |
| |
| |
Capistrano Recipes | |
| |
| |
Capistrano on the Deployment Server | |
| |
| |
Custom Capistrano Tasks | |
| |
| |
Setting Up Your Server Architecture | |
| |
| |
Monolithic Architecture | |
| |
| |
Proxy-Cluster Server: The New Kid on the Block | |
| |
| |
Becoming an Instant Deployment Expert | |
| |
| |
Summary | |
| |
| |
| |
Ruby, a Programmer's Best Friend | |
| |
| |
Instant Interaction | |
| |
| |
Ruby Types | |
| |
| |
Strings | |
| |
| |
Numbers | |
| |
| |
Symbols | |
| |
| |
Arrays and Hashes | |
| |
| |
Language Basics | |
| |
| |
Variables | |
| |
| |
Operators | |
| |
| |
Blocks and Iterators | |
| |
| |
Control Structures | |
| |
| |
Methods | |
| |
| |
Classes and Objects | |
| |
| |
Objects | |
| |
| |
Classes | |
| |
| |
Ruby Documentation | |
| |
| |
| |
Databases 101 | |
| |
| |
Examining a Database Table | |
| |
| |
Working with Tables | |
| |
| |
Selecting Data | |
| |
| |
Inserting Data | |
| |
| |
Updating Data | |
| |
| |
Deleting Data | |
| |
| |
Understanding Relationships | |
| |
| |
SQL and Active Record | |
| |
| |
| |
The Rails Community | |
| |
| |
Rails Mailing Lists | |
| |
| |
Rails IRC Channel | |
| |
| |
Rails Blogs and Podcast | |
| |
| |
Rails Wiki | |
| |
| |
Rails APIs | |
| |
| |
Rails Trac | |
| |
| |
Working with Rails Directory | |
| |
| |
Index | |