O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Agile Web Development with Rails 5.1

Book Description

Learn Rails the way the Rails core team recommends it, along with the tens of thousands of developers who have used this broad, far-reaching tutorial and reference. If you're new to Rails, you'll get step-by-step guidance. If you're an experienced developer, get the comprehensive, insider information you need for the latest version of Ruby on Rails. The new edition of this award-winning classic is completely updated for Rails 5.1 and Ruby 2.4, with information on system testing, Webpack, and advanced JavaScript.

Ruby on Rails helps you produce high-quality, beautiful-looking web applications quickly---you concentrate on creating the application, and Rails takes care of the details. Rails 5.1 brings many improvements, and this edition is updated to cover the new features and changes in best practices.

We start with a step-by-step walkthrough of building a real application, and in-depth chapters look at the built-in Rails features. Follow along with an extended tutorial as you write a web-based store application. Eliminate tedious configuration and housekeeping; seamlessly incorporate Ajax and JavaScript; send emails and manage background jobs with ActiveJob; build real-time features using WebSockets and ActionCable. Test your applications as you write them using the built-in unit, integration, and system testing frameworks; internationalize your applications; and deploy your applications easily and securely. New in this edition is support for Webpack and advanced JavaScript, as well as Rails' new browser-based system testing.

Rails 1.0 was released in December 2005. This book was there from the start, and didn't just evolve alongside Rails, it evolved with Rails. It has been developed in consultation with the Rails core team. In fact, Rails itself is tested against the code in this book.

What You Need:

All you need is a Windows, Mac OS X, or Linux machine to do development on. This book will take you through the steps to install Rails and its dependencies. If you aren't familiar with the Ruby programming language, this book contains a chapter that covers the basics necessary to understand the material in the book.

Table of Contents

  1.  Foreword to the Rails 5 Edition
  2.  Preface to the Rails 5.1 Edition
  3.  Acknowledgments
  4.  Introduction
    1. Rails Simply Feels Right
    2. Rails Is Agile
    3. Who This Book Is For
    4. How to Read This Book
  5. Part I. Getting Started
    1. 1. Installing Rails
      1. Installing on Cloud9
      2. Installing on a Virtual Machine
      3. Installing on Windows
      4. Installing on Mac OS X
      5. Installing on Linux
      6. Choosing a Rails Version
      7. Setting Up Your Development Environment
      8. Rails and Databases
    2. 2. Instant Gratification
      1. Creating a New Application
      2. Hello, Rails!
      3. Linking Pages Together
      4. When Things Go Wrong
    3. 3. The Architecture of Rails Applications
      1. Models, Views, and Controllers
      2. Rails Model Support
      3. Action Pack: The View and Controller
    4. 4. Introduction to Ruby
      1. Ruby Is an Object-Oriented Language
      2. Data Types
      3. Logic
      4. Organizing Structures
      5. Marshaling Objects
      6. Pulling It All Together
      7. Ruby Idioms
  6. Part II. Building an Application
    1. 5. The Depot Application
      1. Incremental Development
      2. What Depot Does
      3. Let’s Code
    2. 6. Task A: Creating the Application
      1. Iteration A1: Creating the Product Maintenance Application
      2. Iteration A2: Making Prettier Listings
    3. 7. Task B: Validation and Unit Testing
      1. Iteration B1: Validating!
      2. Iteration B2: Unit Testing of Models
    4. 8. Task C: Catalog Display
      1. Iteration C1: Creating the Catalog Listing
      2. Iteration C2: Adding a Page Layout
      3. Iteration C3: Using a Helper to Format the Price
      4. Iteration C4: Functional Testing of Controllers
      5. Iteration C5: Caching of Partial Results
    5. 9. Task D: Cart Creation
      1. Iteration D1: Finding a Cart
      2. Iteration D2: Connecting Products to Carts
      3. Iteration D3: Adding a Button
    6. 10. Task E: A Smarter Cart
      1. Iteration E1: Creating a Smarter Cart
      2. Iteration E2: Handling Errors
      3. Iteration E3: Finishing the Cart
    7. 11. Task F: Add a Dash of Ajax
      1. Iteration F1: Moving the Cart
      2. Iteration F2: Creating an Ajax-Based Cart
      3. Iteration F3: Highlighting Changes
      4. Iteration F4: Hiding an Empty Cart with a Custom Helper
      5. Iteration F5: Broadcasting Updates with Action Cable
    8. 12. Task G: Check Out!
      1. Iteration G1: Capturing an Order
      2. Iteration G2: Atom Feeds
    9. 13. Task H: Entering Additional Payment Details
      1. Iteration H1: Adding Fields Dynamically to a Form
      2. Iteration H2: Testing Our JavaScript Functionality
    10. 14. Task I: Processing Emails and Payments Efficiently
      1. Iteration I1: Sending Confirmation Emails
      2. Iteration I2: Connecting to a Slow Payment Processor with Active Job
    11. 15. Task J: Logging In
      1. Iteration J1: Adding Users
      2. Iteration J2: Authenticating Users
      3. Iteration J3: Limiting Access
      4. Iteration J4: Adding a Sidebar, More Administration
    12. 16. Task K: Internationalization
      1. Iteration K1: Selecting the Locale
      2. Iteration K2: Translating the Storefront
      3. Iteration K3: Translating Checkout
      4. Iteration K4: Adding a Locale Switcher
    13. 17. Task L: Deployment and Production
      1. Iteration L1: Deploying with Phusion Passenger and MySQL
      2. Iteration L2: Deploying Remotely with Capistrano
      3. Iteration L3: Checking Up on a Deployed Application
      4. Iteration L4: Deploying with Fewer Steps on Heroku
    14. 18. Depot Retrospective
      1. Rails Concepts
      2. Documenting What We’ve Done
  7. Part III. Rails in Depth
    1. 19. Finding Your Way Around Rails
      1. Where Things Go
      2. Naming Conventions
    2. 20. Active Record
      1. Defining Your Data
      2. Locating and Traversing Records
      3. Creating, Reading, Updating, and Deleting (CRUD)
      4. Participating in the Monitoring Process
      5. Transactions
    3. 21. Action Dispatch and Action Controller
      1. Dispatching Requests to Controllers
      2. Processing of Requests
      3. Objects and Operations That Span Requests
    4. 22. Action View
      1. Using Templates
      2. Generating Forms
      3. Processing Forms
      4. Uploading Files to Rails Applications
      5. Using Helpers
      6. Reducing Maintenance with Layouts and Partials
    5. 23. Migrations
      1. Creating and Running Migrations
      2. Anatomy of a Migration
      3. Managing Tables
      4. Advanced Migrations
      5. When Migrations Go Bad
      6. Schema Manipulation Outside Migrations
    6. 24. Customizing and Extending Rails
      1. Testing with RSpec
      2. Creating HTML Templates with Slim
      3. Serving CSS via Webpack
      4. Customizing Rails in Other Ways
      5. Where to Go from Here
  8.  Bibliography