Rails 4 in Action: Revised Edition of Rails 3 in Action
Ryan Bigg, Yehuda Katz, Steve Klabnik, and Rebecca Skinner
Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
orders@manning.com2015 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
| Manning Publications Co.20 Baldwin RoadPO Box 761Shelter Island, NY 11964 | Development editor: Susan ConantTechnical editor: Steven JenkinsCopyeditor: Andy CarrollProofreader: Katie TennantTechnical proofreader: Doug WarrenTypesetter: Gordan SalinovicCover designer: Marija Tudor |
ISBN 9781617291098
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 EBM 20 19 18 17 16 15
Brief Table of Contents
Table of Contents
Praise for Rails 3 in Action
Takes you on an excellent Rails 3 adventure!
Anthony J. Topper, Penn State Harrisburg
Conversational and current. A wellspring of information.
Jason Rogers, Dell Inc.
An essential roadmap for the newest features of Rails 3.
Greg Vaughn, Improving Enterprises
Essential, effective Rails techniques and habits for the modern Rubyist.
Thomas Athanas, Athanas Empire, Inc.
A holistic book for a holistic framework.
Josh Cronemeyer, ThoughtWorks Studios
The API chapter was an absolute lifesaver, and if I hadnt read it I wouldnt have been able to write my application that I have now deployed.
Leo Cassarani
I think Ive learned more about Rails in the first five chapters than I did in all the other resources Ive tried ... combined!
J.K. Wood
The writing in the book is natural and relaxed, and it takes us through the process of developing an application. In doing so, it references and shows us how to use specific non-base Rails gems that really help in achieving our goals.
Mario Alberto Chvez Crdenas
Preface
I came to be an author on this book back in April 2010, and then spent about a year and a half writing it from scratch while working full-time. The first edition, Rails 3 in Action, was published in September of 2011. Its now 2015 and the revised edition is finally here, this time focusing on Rails 4.2 instead of Rails 3.1.
During this time, many changes have come to pass in the Ruby and Rails community, with almost 40 new versions of Rails since 3.1. The way we whitelist data attributes received from the outside world has moved from the models to the controllers. The popularity of Cucumber (a staple in the first edition) has faded, and it has been replaced by RSpec and Capybara. Validation syntax has morphed. The find_by_* finders have been deprecated. And so much more.
By the time this book goes to print, Rails 5 will be due for release. Rails changes much faster than other frameworks, and with good reasonthe community around it is actively evolving the best ways to write web applications. Other frameworks (or even languages, cough Java), evolve much more slowly. My thoughts about publishing this book, even though Rails 5 is coming soon, are these: Its worthwhile to know Rails 4 and to have a good grasp of how applications are built. This book is a good indication of where the community is in terms of getting started with Rails at this particular point in time.
Days (here and there) and nights (mostly) have gone into updating this book. Not one page has gone without review. Its our utmost pleasure to bring you a book that is up to date after such a long wait. Never did I think it would take this long between publications, but thats how things played out. Good feels is an apt expression to explain what its like to finally have this book done.
So heres the book youve all been waiting for. Use it well. Capture the knowledge within its pages. Know this: This book has been used by many people to jump-start their careers in Rails, and you could be next. Skimming through these pages wont get you there, but reading it thoroughly and applying the lessons in it just might.
Good luck.
R YAN B IGG
Acknowledgments
This book has been a long time coming, so I would like to say thanks to you, the reader, for waiting as long as you have for this revised edition.
Id like to thank Steve Klabnik for taking over as an author after I left the project. He got the book a long way toward being compatible with Rails 4, and without his efforts this would have taken even longer to do. Thanks to my other coauthor, Rebecca Skinner, for joining the project and helping tremendously with updating the book. Rebecca rewrote at least three chapters and has pored over the others for many hours to make this book as good as it can be.
Along with Rebecca, special mention goes to Justin Lane and Ivan Polchenko, who put in an excellent effort on reviewing this book. They showed great dedication by providing feedback nearly every day on IRC or by email.
Wed also like to thank the other reviewers who volunteered to help out with the book: Andrew Grimm, Andrew Hoffman, Andy Henson, Ben Woodall, Bredan Murtagh, Cory Simmons, Dana Jones, D. Deryl Downey, Eduardo Bautista, Jimmy Beaudoin, Harry Moreno, Paulo Toro, Sushruth Sivaramakrishnan, Johnneylee Jack Rollins, Tamara Temple, David Workman, and Yaw Boakye. These reviewers span the globe: America, Australia, India, the UK, and Ghana. To be able to collaborate with such a diverse group of people is fantastic.
The creators of the tools that we use to publish books also deserve a mention: The wonderful people at GitHub, for providing a service that lets people worldwide collaborate with ease on projects such as these. Stuart Rackham, the creator of AsciiDoc, for proving that theres a better way to write books than in Microsoft Word, XML, or Markdown. Dan Allen, for writing Asciidoctor, which we used to compile the HTML and PDF versions of the book that we shared with our reviewers.
Thanks to everyone at Manning, from my development editor Susan Conant to technical editor Steven Jenkins to technical proofreader Doug Warren to everyone on the production team to the marketing folksand to many more who worked behind the scenes.
Also thanks to the following peer reviewers who read the manuscript at various stages of its development: Alex Perucchini, Michele Bursi, Damien White, Eddie Welker, Gavin Whyte, Greg Helton, Jared Hirsch, Justin Wiley, Lee Allen, Mike Gehard, Nathan Bean, Paul Hollyer, Robert OConnor, Steve Robertson, William E. Wheeler, and William Ko. Your comments and insights made this a better book!