Rails Crash Course

Rails Crash Course
A No-Nonsense Guide to Rails Development
Anthony Lewis
October 2014, 296 pp.

Rails is a robust, flexible development platform that lets you build complex websites quickly. Major websites like GitHub, Hulu, and Twitter have run Rails under the hood, and if you know just enough HTML and CSS to be dangerous, Rails Crash Course will teach you to harness Rails for your own projects and create web applications that are fast, stable, and secure.

In Part I, you’ll learn Ruby and Rails fundamentals and then dive straight into models, controllers, views, and deployment. As you work through the basics, you’ll learn how to:

  • Craft persistent models with Active Record
  • Build view templates with Embedded Ruby
  • Use Git to roll back to previous versions of your code base
  • Deploy applications to Heroku

In Part II, you’ll take your skills to the next level as you build a social networking app with more advanced Ruby tools, such as modules and metaprogramming, and advanced data modeling techniques within Rails’s Active Record. You’ll learn how to:

  • Implement an authentication system to identify authorized users
  • Write your own automated tests and refactor your code with confidence
  • Maximize performance with the asset pipeline and turbolinks
  • Secure your app against SQL injection and cross-site scripting
  • Set up a server and deploy applications with Capistrano

Each chapter is packed with hands-on examples and exercises to reinforce what you’ve learned. Whether you’re completely new to Ruby or you’ve been mucking around for a bit, Rails Crash Course will take you from the basics to shipping your first Rails application, fast.

Author Bio 

Anthony Lewis has been building websites since 1994. A Senior Engineer at Spredfast (formerly Mass Relevance) and one of the developers behind the Spark social marketing platform, Lewis writes Ruby on Rails and JavaScript code daily. He runs workshops at the Lone Star Ruby Conference, provides in-depth Rails trainings, and is an active member of Austin on Rails.

Table of contents 


Part I: Ruby on Rails Fundamentals

Chapter 1: Ruby Fundamentals
Chapter 2: Rails Fundamentals
Chapter 3: Models
Chapter 4: Controllers
Chapter 5: Views
Chapter 6: Deployment

Part II: Building a Social Networking App

Chapter 7: Advanced Ruby
Chapter 8: Advanced Active Record
Chapter 9: Authentication
Chapter 10: Testing
Chapter 11: Security
Chapter 12: Performance
Chapter 13: Debugging
Chapter 14: Web APIs
Chapter 15: Custom Deployment



View the detailed Table of Contents (PDF).

View the Index (PDF).


"If you want to learn one of the most effective modern tools for web site development -- quickly, easily and well -- this book is for you."
IT World (Read More)

"A perfect balance...a busy developer will become fluent within days. "
Optimal Works (Read More)


Windows Users:
If you're using Windows, follow the instructions below to install Ruby, Rails, and Git instead of the ones on page xxii. Throughout the book, when asked to enter commands such as bin/rake and bin/rails, add ruby before those commands (for example, ruby bin/rake and ruby bin/rails).

Windows Installation Instructions:
You’ll use RubyInstaller to install Ruby. Download the RubyInstaller and the matching Development Kit here.

First, click the latest Ruby version on the RubyInstaller download page to download the installer; at the time of writing, it’s 2.1.5. Then scroll down to the section labeled Development Kit and click the link under your version of Ruby to download the Development Kit. As of this writing, for Ruby 2.1, you’d choose DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe. If you are using a 64-bit version of Windows, then download the 64-bit version of the installer and the matching 64-bit Development Kit, currently DevKit-mingw64-64-4.7.2-20130224-1151-sfx.exe.

Once these downloads finish, double-click the RubyInstaller file and then follow the prompts on your screen to install Ruby. Be sure to check the box next to Add Ruby executables to your PATH. Once that is complete, double-click the DevKit file and enter the path C:\DevKit to extract the files. Now open a command prompt and enter the following commands to install the Development Kit:

$ cd C:\DevKit
$ ruby dk.rb init
$ ruby dk.rb install

Some users see SSL errors when trying to install gems. Updating to the latest version of the gem command corrects these errors. Enter the following command to update your version of gem:

$ gem update --system –-clear-sources –-source http://rubygems.org

Once you’ve installed Ruby and the Development Kit, install Rails by entering gem install rails. This will connect to the RubyGems server and then download and install the various packages that make up the Ruby on Rails framework.

Finally, download the latest version of Git and double-click the file to complete the installation.

Page 12:
The three examples should read as follows:

irb(main):053:0> name = "Tony"
=> "Tony"
irb(main):054:0> if !name.empty?
irb(main):055:1> puts name
irb(main):056:1> end
=> nil


irb(main):057:0> name = "Tony"
=> "Tony"
irb(main):058:0> unless name.empty?
irb(main):059:1> puts name
irb(main):060:1> end
=> nil


irb(main):061:0> name = "Tony"
=> "Tony"
irb(main):062:0> puts name unless name.empty?
=> nil