Agile Web Development with Rails
Fourth Edition
by Sam Ruby, Dave Thomas, David Heinemeier Hansson
Version: P2.0 (August 2011)
Copyright 2011 Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trust-don't allow others to use your copy of the book. Thanks.
- Dave & Andy.
Table of Contents
Copyright 2011, The Pragmatic Bookshelf.
When I started learning Ruby on Rails, I read the first edition of this book. Its holistic view of the Rails framework and community provides any new developer the kick start they need to a highly successful career. After reading through the latest edition cover to cover, I can happily say that it continues that trend and remains the first book I recommend to any new Rails developer.
Mikel Lindsaar |
Rails core commit team, creator of the Ruby Mail library, and director, RubyX |
Agile Web Development with Rails does an excellent job of making the Rails environment accessible in an enjoyable and memorable way. In addition, this book is the first Ive seen that provides a sensible and coherent explanation of the MVC pattern, and it does so in a natural progression using examples that completely remove any mystery.
Ken Coar |
Author, open software evangelist, and Apache developer |
Agile Web Development with Rails successfully straddles a fine line between being a fun-to-read introduction to Rails (and Ruby) and a straightforward guide to some advanced features of the platform, nicely supplanting the ever-changing online documentation.
Glen Daniels |
Independent technologist and consultant |
Ive never read a programming book as successful as Agile Web Development with Rails . Sam made learning Ruby on Rails easy, comprehensive, and fun.
Keith Ballinger |
Chairman of WS-Is first Basic Profile working group; author; and key contributor to the .NET and Visual Studio .NET frameworks |
Preface to the Fourth Edition
When Dave asked me to join as a coauthor of the third edition of this book, I was thrilled. After all, it was from the first printing of the first edition of this book that I had learned Rails. Dave and I also have much in common. Although he prefers Emacs and Mac OS X and my preferences tend toward Vim and Ubuntu, we both share a love for the command line and getting our fingers dirty with codestarting with tangible examples before diving into heavy theory.
Since the time the third edition was published (and, in fact, since the first, second, and third editions), much has changed. Rails is in the process of being significantly refactored, mostly internally. A number of features that were used in previous examples have been initially deprecated and subsequently removed. New features have been added, and much experience has been obtained as to what the best practices are for using Rails. Rails now also works on Ruby 1.9, and each of the examples has been tested with Ruby 1.8.7 and Ruby 1.9.2.
Additionally, Rails has exploded from being a popular framework to an active and vibrant ecosystem, complete with many popular plugins and deep integration into third-party tools. In the process, Rails has become mainstream, attracting a more diverse set of developers to the framework.
This has led to a reorganization of the book. Many newcomers to Rails have not had the pleasure of being introduced to Ruby, so this section has been promoted from an appendix to a chapter in Part I. We follow Part I with a step-by-step walk-through of building a real application, which has been updated and streamlined to focus on current best practices.
But the biggest change is in the final part: because it is no longer practical to cover the entire ecosystem of Rails given both its breadth and rate of change, this part is now focused on providing an overall perspective of the landscape, enabling you, the reader, to know what to look for and where to find plugins and related tools to address common needs that go far beyond what the framework itself contains.
In short, this book needed to adapt. Once again.
Sam Ruby
March 2011
Copyright 2011, The Pragmatic Bookshelf.
Preface to the Rails 3.1 Version of This Book
This book is written for Rails 3.1.
The Rails core team is continuing to work on Rails. From time to time, new releases may introduce incompatibilities for applications written for prior versions of Rails, including the code in this book.
To run the examples provided in this book, it is important that you install the correct version of Rails, as described in Chapter 1,
To determine the version of Rails that you are running, you can issue rails -v
at a command prompt.
Information on changes to Rails that affect this book can be found at http://www.pragprog.com/wikis/wiki/ChangesToRails.
Even though Rails 3.1 is purportedly only a minor release and includes few major internal changes (certainly as compared to the changes made between Rails 2.3.x and Rails 3.0), it contains a significant number of user-facing changes that affect this book. As such, the Pragmatic Bookshelf team decided to update this book to reflect these changes.
Heres an overview of some of the bigger changes:
Generated code is aware of which version of Ruby you are using. It will take advantage of the new and cleaner hash value syntax available in Ruby 1.9.2, and will also format the output of tests differently.
Asset management is now a core part of Rails. This changes where you place a number of files, and adds a step to deployment.
SCSS is available by default, which changes both the syntax and the organization of all of the stylesheets.
JQuery replaces Prototype and Script.aculo.us, changing the JavaScript code that you will write in Chapter 11, .
CoffeeScript is available by default, which changes the syntax of client-side scripts.
Migration methods are no longer class methods, and in most cases are automatically reversible.
Default serialization of responses is now JSON instead of XML. There also is a handy new j
view helper that makes producing JSON (and JavaScript in general) responses easier.
A has_secure_password
method has been added to the model, which encapsulates and standardizes common user password hashing logic.
Rack::Cache
is enabled by default in production.
The mysql2
gem replaces mysql
gem.
For further details, see the release notes.
Footnotes
http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate |
Copyright 2011, The Pragmatic Bookshelf.
Acknowledgments
Youd think that producing a new edition of a book would be easy. After all, you already have all the text. Its just a tweak to some code here and a minor wording change there, and youre done. Youd think.
Its difficult to tell exactly, but our impression is that creating each edition of Agile Web Development with Rails took about as much effort as the first edition. Rails is constantly evolving and, as it does, so has this book. Parts of the Depot application were rewritten several times, and all of the narrative was updated. The emphasis on REST and the avoidance of features as they become deprecated have repeatedly changed the structure of the book as what was once hot became just lukewarm.