Crafting Rails 4 Applications, 2nd Edition

Book description

Get ready to see Rails as you've never seen it before. Learn how to extend the framework, change its behavior, and replace whole components to bend it to your will. Eight different test-driven tutorials will help you understand Rails' inner workings and prepare you to tackle complicated projects with solutions that are well-tested, modular, and easy to maintain.

This second edition of the bestselling Crafting Rails Applications has been updated to Rails 4 and discusses new topics such as streaming, mountable engines, and thread safety.

Rails is one of the most extensible frameworks out there. This pioneering book deep-dives into the Rails plugin APIs and shows you, the intermediate Rails developer, how to use them to write better web applications and make your day-to-day work with Rails more productive.

Rails Core developer Jose Valim guides you through eight different tutorials, each using test-driven development to build a new Rails plugin or application that solves common problems with these APIs. You'll learn how the Rails rendering stack works and customize it to read templates from the database while you discover how to mimic Active Record behavior, such as validations, in any other object. You'll find out how Rails integrates with Rack, the different ways to stream data from your web application, and how to mix Rails engines and Sinatra applications into your Rails apps, so you can choose the most appropriate tool for the job. In addition, you'll improve your productivity by customizing generators and responders.

This book will help you understand Rails' inner workings, including generators, template handlers, internationalization, routing, and responders. With the knowledge you'll gain, you'll create well-tested, modular, and robust solutions for your next project.

Table of contents

  1. Crafting Rails 4 Applications
  2. For the Best Reading Experience...
  3. Table of Contents
  4. Early praise for Crafting Rails 4 Applications
  5. Acknowledgments
  6. Preface
    1. Who Should Read This Book?
    2. What Is in the Book?
    3. Changes in the Second Edition
    4. How to Read This Book
    5. Online Resources
  7. Chapter 1: Creating Our Own Renderer
    1. Creating Your First Rails Plug-in
    2. Writing the Renderer
    3. Understanding the Rails Rendering Stack
    4. Taking It to the Next Level
    5. Wrapping Up
  8. Chapter 2: Building Models with Active Model
    1. Creating Our Model
    2. Integration Tests with Capybara
    3. Taking It to the Next Level
    4. Wrapping Up
  9. Chapter 3: Retrieving View Templates from Custom Stores
    1. Revisiting the Rendering Stack
    2. Setting Up a SqlResolver
    3. Configuring Our Resolver for Production
    4. Serving Templates with Metal
    5. Wrapping Up
  10. Chapter 4: Sending Multipart Emails Using Template Handlers
    1. Playing with the Template-Handler API
    2. Building a Template Handler with Markdown + ERB
    3. Customizing Rails Generators
    4. Extending Rails with Railties
    5. Wrapping Up
  11. Chapter 5: Streaming Server Events to Clients Asynchronously
    1. Extending Rails with Engines
    2. Live Streaming
    3. Filesystem Notifications with Threads
    4. Code-Loading Techniques
    5. Wrapping Up
  12. Chapter 6: Writing DRY Controllers with Responders
    1. Understanding Responders
    2. Exploring ActionController::Responder
    3. The Flash Responder
    4. HTTP Cache Responder
    5. More Ways to Customize Generators
    6. Wrapping Up
  13. Chapter 7: Managing Application Events with Mountable Engines
    1. Mountable and Isolated Engines
    2. Storing Notifications in the Database
    3. Rails and Rack
    4. Middleware Stacks
    5. Streaming with Rack
    6. Wrapping Up
  14. Chapter 8: Translating Applications Using Key-Value Back Ends
    1. Revisiting Rails::Application
    2. I18n Back Ends and Extensions
    3. Rails and Sinatra
    4. Taking It to the Next Level with Devise and Capybara
    5. Wrapping Up
    6. You May Be Interested In…

Product information

  • Title: Crafting Rails 4 Applications, 2nd Edition
  • Author(s): Jose Valim
  • Release date: November 2013
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781680503302