Sam Ruby, David Bryant Copeland, Dave Thomas
Web_Development#
web_applications#
WebSockets#
ActionCable#
Webpack#
Ajax#
JavaScript#
Rails#
Ruby#
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 6 and Ruby 2.6, 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 6 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 and receive emails, manage background jobs with ActiveJob, and 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 coverage of Action Mailer, which allows you to receive emails in your app as well as ActionText, a zero-configuration rich text editing feature.
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.
Rails 1.0 was released in December 2005. In the years since, it has gone from a relatively unknown leading-edge tool to a successful and stable foundation with a large set of associated libraries that others benchmark themselves against.\
The book you’re about to read was there from the start, and it has evolved with Rails. It began as a full reference to a small framework when online documentation was scarce and inconsistent. It’s now an introduction to the entire Rails ecosystem—one that leaves you with many pointers to more information that you can explore based on your needs and desires.
This book didn’t just evolve along with Rails: Rails evolved with it. The content in this book has been developed in consultation with the Rails core team. Not only is the code you’ll see in this book tested against each release of Rails, but the converse is also true: Rails itself is tested against the code in this book and won’t be released until those tests pass.
So read this book with confidence that the scenarios not only work but also describe how the Rails developers themselves feel about how best to use Rails. We hope you get as much pleasure out of reading this book as we had in developing it.
This book covers Rails 6. While some of the commands you’ll be using are new, the underlying development model remains the same. Even when new major features are added, such as the ability to process incoming emails with Action Mailbox, changes are evolutionary, not revolutionary.
Rails 6 introduced two major new features and a lot of small improvements. While Rails has always had strong support for sending emails, Rails’ ability to receive emails has been fairly limited until now. Action Mailbox introduces the concept of Mailboxes, which are controllers for processing incoming emails. You can use mailboxes to access any part of an incoming email, and then trigger any workflow or logic, the same as you would in a normal controller.
Rails 6 also adds seamless support for rich-text editing & management via Action Text. Action Text is an end-to-end integration of the Trix rich text editor to your Rails app using Active Storage. With almost no configuration, you can present a rich text editor to your users, save that rich text, and render it back wherever you want, either as formatted text or plain text. This is a great example of how Rails takes what could be a complicated set of disparate components & brings them together so they work whenever you need them to.
We’ve also updated the setup instructions to focus on Windows, macOS, and Linux. Since Cloud 9 was acquired by Amazon, it’s now a bit more difficult to use as a way to learn Rails. To that end, our setup instructions for Linux now assume you are doing this inside a virtual machine, which should provide a stable, repeatable environment in which to learn Rails.
We’ll walk you through that setup if you wish to learn Rails that way.
Extra Q&A with the Authors
Why did you decide to make a new edition of this book?
The Rails Doctrine states the Rails favors progress over stability. Thus, it's important to us that, as Rails progresses, so should this book. We want this book to to show you not just what you can do with Rails, but the state of the art in how to do that.
It's not an easy task. The first two versions of this book were written by Dave Thomas. Sam Ruby took the lead on updating it for new versions of Rails after that, with David Copeland joining more recently.
All three of the co-authors have been wrangled and managed by first Susannah Pfalzer as editor and now by Adaobi Obi Tulton. We all really think it's important that this book stays as relevant as Rails.
What kind of experience would help getting the most out of this book?
Rails is great if you are a total beginner, and the book allows a beginner with just a bit of programming knowledge to be able to get an app up and runnign easily. But, if you are more experienced with other ways of doing web development, you'll get even more out of the book because you'll get more out of Rails. You'll experience clean patterns and APIs for stuff you might be used to making by hand on each project, and it'll feel like a breath of fresh air.
What do you hope readers take away from this book?
Two things: first, that Rails is as relevant as ever to building modern web applications, and second, that Rails is accessible to everyone: from the least to most experienced developers, Rails will make them more productive.
What's your favorite part of the book?
The chapter we added on Action Mailbox and Action Text is a great example of the power of Rails. These are two new features that weren't designed together but integrate perfectly. Action Mailbox is a high level way to receive emails into your Rails app, which was previously pretty difficult to do and kind of messy. Action Mailbox treats incoming emails the same as an incoming web request. We then use Action Text to allow responding to these emails in rich text. Action Text is a complex JavaScript WYSIWYG widget that seamlessly integrates into Rails, and we use that to send those rich text messages as formatted emails using Action Mailer. Doing all this takes very few lines of code. It's a great demonstration of the power Rails gives you.
About the Author
Sam Ruby is president of the Apache Software Foundation, previously co-chaired the W3C HTML Working Group, and has made significant contributions to many open source projects and standards.
David Bryant Copeland has been a professional programmer since 1995. He's the author of Build Awesome Command-Line Applications in Ruby 2 and Rails, Angular, Postgres, and Bootstrap. He has worked at LivingSocial and Opower, and is the Chief Software Architect at Stitch Fix.
Dave Thomas, as one of the authors of the Agile Manifesto, understands agility. As the author of Programming Ruby, he understands Ruby. And, as an active Rails developer, he knows Rails.