#1 Amazon Bestseller in Lean Management Discover the methods of lean startups that can revolutionize large organizations and their products Even in a tough economic climate, the startup business community has found a way to create innovative, game...
#1 Amazon Bestseller in Lean Management Discover the methods of lean startups that can revolutionize large organizations and their products Even in a tough economic climate, the startup business community has found a way to create innovative, game...
Praise for the Previous Edition This encyclopedic book is not only a definitive Rails reference, but an indispensable guide to Software-as-a-Service coding techniques for serious craftspersons. I keep a copy in the lab, a copy at home, and a copy on each of my three e-book readers, and it's on the short list of essential resources for my undergraduate software engineering course. --Armando Fox, adjunct associate professor, University of California, Berkeley Everyone interested in Rails, at some point, has to follow The Rails Way. --Fabio Cevasco, senior technical writer, Siemens AG, and blogger at H3RALD.com I can positively say that it's the single best Rails book ever published to date. By a long shot. --Antonio Cangiano, software engineer and technical evangelist at IBM This book is a great crash course in Ruby on Rails! It doesn't just document the features of Rails, it filters everything through the lens of an experienced Rails developer--so you come our a pro on the other side. --Dirk Elmendorf, co-founder of Rackspace, and Rails developer since 2005 The key to The Rails Way is in the title. It literally covers the "way" to do almost everything with Rails. Writing a truly exhaustive reference to the most popular Web application framework used by thousands of developers is no mean feat. A thankful community of developers that has struggled to rely on scant documentation will embrace The Rails Way with open arms. A tour de force! --Peter Cooper, editor, Ruby Inside In the past year, dozens of Rails books have been rushed to publication. A handful are good. Most regurgitate rudimentary information easily found on the Web. Only this book provides both the broad and deep technicalities of Rails. Nascent and expert developers, I recommend you follow The Rails Way. --Martin Streicher, chief technology officer, McLatchy Interactive; former editor-in-chief of Linux Magazine Hal Fulton's The RubyWay has always been by my side as a reference while programming Ruby. Many times I had wished there was a book that had the same depth and attention to detail, only focused on the Rails framework. That book is now here and hasn't left my desk for the past month. --Nate Klaiber, Ruby programmer As noted in my contribution to the Afterword: "What Is the Rails Way (To You)?," I knew soon after becoming involved with Rails that I had found something great. Now, with Obie's book, I have been able to step into Ruby on Rails development coming from .NET and be productive right away. The applications I have created I believe to be a much better quality due to the techniques I learned using Obie's knowledge. --Robert Bazinet, InfoQ.com, .NET and Ruby community editor, and founding member of the Hartford, CT, Ruby Brigade Extremely well written; it's a resource that every Rails programmer should have. Yes, it's that good. --Reuven Lerner, Linux Journal columnist
Obie Fernandez has been hacking computers since he got his first Commodore VIC-20 in the eighties, and found himself in the right place and time as a programmer on some of the first Java enterprise projects of the mid-nineties. Obie has been evangelizing Ruby on Rails online via blog posts and publications since early 2005. Since then, he has traveled around the world relentlessly promoting Rails at large industry conferences. As CEO and Founder of Hashrocket, Obie specializes in orchestrating the creation of large-scale, web-based applications, both for startups and mission-critical enterprise projects. He still gets his hands dirty with code on at least a weekly basis and posts regularly on various topics to his popular technology weblog blog.obiefernandez.com.
Foreword by David Heinemeier Hansson xxxiii
Foreword by Yehuda Katz xxxv
Introduction xxxvii
Acknowledgments xliii
About the Author xlv
Chapter 1: Rails Environments and Configuration 1
1.1 Bundler 2
1.2 Startup and Application Settings 8
1.3 Development Mode 15
1.4 Test Mode 19
1.5 Production Mode 20
1.6 Logging 23
1.7 Conclusion 29
Chapter 2: Routing 31
2.1 The Two Purposes of Routing 32
2.2 The routes.rb File 33
2.3 Route Globbing 45
2.4 Named Routes 46
2.5 Scoping Routing Rules 50
2.6 Listing Routes 53
2.7 Conclusion 54
Chapter 3: REST, Resources, and Rails 55
3.1 REST in a Rather Small Nutshell 55
3.2 Resources and Representations 56
3.3 REST in Rails 57
3.4 Routing and CRUD 58
3.5 The Standard RESTful Controller Actions 61
3.6 Singular Resource Routes 64
3.7 Nested Resources 65
3.8 RESTful Route Customizations 69
3.9 Controller-Only Resources 74
3.10 Different Representations of Resources 76
3.11 The RESTful Rails Action Set 78
3.12 Conclusion 83
Chapter 4: Working with Controllers 85
4.1 Rack 86
4.2 Action Dispatch: Where It All Begins 88
4.3 Render unto View 92
4.4 Additional Layout Options 101
4.5 Redirecting 101
4.6 Controller/View Communication 104
4.7 Filters 105
4.8 Verification 111
4.9 Streaming 112
4.10 Conclusion 117
Chapter 5: Working with Active Record 119
5.1 The Basics 120
5.2 Macro-Style Methods 121
5.3 Defining Attributes 123
5.4 CRUD: Creating, Reading, Updating, Deleting 127
5.5 Database Locking 142
5.6 Where Cl...