Head First Rails
Looking to take your web applications beyond stodgy, and into the Web 2.0 generation? Head First Rails takes your programming—and productivity—to the max. You'll learn everything from the fundamentals of Rails scaffolding to building customized interactive web apps, all using Rails' rich set of tools and the MVC framework.
By the time you're finished, you'll know more than just another web framework. You'll master database interactions, integration with Ajax and XML, rich content, and even dynamic graphing of your data... all in a fraction of the time it takes to build the same apps with Java, PHP, ASP.NET, or Perl. You'll even get comfortable and familiar with Ruby... but you'll do it in the context of web programming, not another boring version of "Hello, World!"
We think your time is too valuable to waste struggling with new concepts. Using the latest research in cognitive science and learning theory to craft a multi-sensory learning experience, Head First Rails uses a visually rich format designed for the way your brain works, not a text-heavy approach that puts you to sleep.
Table of Contents
1. Really Rapid Rails: Getting Started
2. Rails Apps, Made to Order: Beyond Scaffolding
3. Everything Changes: Inserting, Updating, and Deleting
4. Truth or Consequences: Database Finders
5. Preventing Mistakes: Validating Your Data
6. Bringing It All Together: Making Connections
7. Avoiding the Traffic: Ajax
8. It All Looks Different: XML and Multiple Representations
9. Taking Things Further: REST and Ajax
10. Rails in the Real World: Real-World Applications
What you should know before reading this book
This is a learning experience, not a reference book. We deliberately stripped out everything that might get in the way of learning whatever it is we're working on at that point in the book. And the first time through, you need to begin at the beginning because the book makes assumptions about what you've already seen and learned.
Before you begin this book you will need to get Ruby on Rails installed on your machine.This is not a how-to book, so we don't have any chapters that give you instructions on how to install Ruby on Rails on your computer. It's better to get that kind of information from the web. You will need to install Ruby on Rails version 2.1 or above, as well as SQLite 3. You can find out more from http://www.rubyonrails.org/down
This is not a reference book.So don't expect to see lots and lots of pages explaining 15 different ways to do something. We want you to understand by doing, so right from the get-go, we'll give you just enough information to move your learning forward. By the end of the book, you will have a mental framework of how Rails works and what it can do. You will then be able to slot the reference material into your brain much more rapidly and meaningfully than you would have been able to before. Psychologists call this the ability to chunk information.
All of the code in this book is available on the Head First site.We'll present all of the code you'll need as we go along. It's a good idea to program along with the book, and it's a great idea to play around with the code and make it do your own thing. But sometimes you may want a copy of the code used in each chapter, so we've made it available on the Head First Labs web site. Rails applications are quite self-contained, so there's no reason why you can't have the code that does what the book says it should do, alongside your own buffed and pimped out version. You can download the code from this page.
We don't fully explain every piece of code.Rails can generate a lot of code for you, and we don't want you to get bogged down in line-by-line descriptions. We'll describe the important parts that you need to know, and then we'll move on. Don't worry—by the end of the book, all of the pieces should fall into place.
This is a Rails book, not a Ruby book.
Ruby is the language that the Rails framework is written in, and we'll teach you just enough Ruby as we go along. Don't worry—if you have some experience of another programming language like C# or Java, you'll do just fine. Rails is such a powerful system that you can get a very long way with just a little Ruby knowledge.
Chapter 1: Getting Started Chapter 2: Going Beyond Scaffolding
development.sqlite3: This is the test database for use with the project in Chapter 2. After you have created the database tables using
rake db:migrateyou will need to replace the db/development.sqlite3 file with this file.
chap2_hfrails_code_stylesheets_and_images.zip: This file contains the stylesheets and images directories mentioned on Page 93 in Chapter 2.
Chapter 3: Inserting, Updating and Deleting Chapter 4: Using Database Finders Chapter 5: Validating Your Data Chapter 6: Making Connections Chapter 7: Dynamic Ajax Chapter 8: XML and Multiple Representations Chapter 9: REST and AjaxThere is no code for Chapter 10.
"Head First Rails continues the tradition of the Head First series, providing useful, real-world information to get you up and going quickly. Head First Rails is an excellent book for people learning Rails, as well as those brushing up on the latest features."
— Jeremy Durham, Web Developer
"I wish this book was out when I was getting started with Rails. It would have helped immensely."
— Mike Isman, Web Developer
"I love the Head First Books. They are both educational and entertaining!!"
— LuAnn Mazza
"Head First Rails is a great, broad introduction to iterative Web 2.0 development. This book will show you how quick and easy it is to develop robust, next-generation websites."
— Matt Proud, Systems Administrator and Developer
If you can answer "yes" to all of these, this book is for you:
- Are you comfortable with HTML?
- Do you have some experience of a computer language like Java, C# or PHP?
- Do you want to build cool stuff for the web in a fraction of the time it used to take?
You should probably back away from this book if you can answer "yes" to any of these:
- Are you someone who doesn't have any experience with HTML? (try Head First HTML instead)
- Are you an accomplished Rails developer looking for a reference book?
- Are you afraid to try something different? Would you rather have a root canal than mix stripes with plaid? Do you believe a technical book can't be serious if it anthropomorphizes clients and servers?