Ruby on Rails 3 Tutorial: Learn Rails by Example (Addison-Wesley Professional Ruby)

Ruby on Rails 3 Tutorial: Learn Rails by Example (Addison-Wesley Professional Ruby)

Michael Hartl

Language: English

Pages: 576

ISBN: 0321743121

Format: PDF / Kindle (mobi) / ePub


Ruby on Rails™ 3 Tutorial: Learn Rails by Example by Michael Hartl has become a must read for developers learning how to build Rails apps.”

—Peter Cooper, Editor of Ruby Inside

 

Using Rails 3, developers can build web applications of exceptional elegance and power. Although its remarkable capabilities have made Ruby on Rails one of the world’s most popular web development frameworks, it can be challenging to learn and use. Ruby on Rails™ 3 Tutorial is the solution. Leading Rails developer Michael Hartl teaches Rails 3 by guiding you through the development of your own complete sample application using the latest techniques in Rails web development.

 

Drawing on his experience building RailsSpace, Insoshi, and other sophisticated Rails applications, Hartl illuminates all facets of design and implementation—including powerful new techniques that simplify and accelerate development.

 

You’ll find integrated tutorials not only for Rails, but also for the essential Ruby, HTML, CSS, JavaScript, and SQL skills you’ll need when developing web applications. Hartl explains how each new technique solves a real-world problem, and he demonstrates this with bite-sized code that’s simple enough to understand, yet novel enough to be useful. Whatever your previous web development experience, this book will guide you to true Rails mastery.

 

This book will help you

  • Install and set up your Rails development environment
  • Go beyond generated code to truly understand how to build Rails applications from scratch
  • Learn Test Driven Development (TDD) with RSpec
  • Effectively use the Model-View-Controller (MVC) pattern
  • Structure applications using the REST architecture
  • Build static pages and transform them into dynamic ones
  • Master the Ruby programming skills all Rails developers need
  • Define high-quality site layouts and data models
  • Implement registration and authentication systems, including validation and secure passwords
  • Update, display, and delete users
  • Add social features and microblogging, including an introduction to Ajax
  • Record version changes with Git and share code at GitHub
  • Simplify application deployment with Heroku

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

working for now. We’ll remove the default page (and replace it with a custom home page) in Section 5.2.2. 15. You can also access the application by visiting 0.0.0.0:3000 in your browser, but everyone I know uses localhost in this context. 16. Windows users may have to download the SQLite DLL from sqlite.org and unzip it into their Ruby bin directory to get this to work. (Be sure to restart the local web server as well.) 22 Chapter 1: From Zero to Deploy Figure 1.4 The default page

# git status On branch modify-README Changes to be committed: (use "git reset HEAD ..." to unstage) renamed: README -> README.markdown Changed but not updated: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: README.markdown At this point, we could use git add . as in Section 1.3.2, but Git provides the -a flag as a shortcut for the (very common) case of committing all modifications to

a typical browser hit—a visit to the user index page at /users—in terms of MVC (Figure 2.11, page 55). The steps in Figure 2.11: 1. 2. 3. 4. 5. 6. The browser issues a request for the /users URL. Rails routes /users to the index action in the Users controller. The index action asks the User model to retrieve all users (User.all). The User model pulls all the users from the database. The User model returns the list of users to the controller. The controller captures the users in the @users

microblogging site—a site which, coincidentally, is also written in Rails. Though of necessity our efforts will focus on this specific sample application, the emphasis throughout Rails Tutorial will be on general principles, so that you will have a solid foundation no matter what kinds of web applications you want to build. Box 1.1 Scaffolding: Quicker, easier, more seductive From the beginning, Rails has benefited from a palpable sense of excitement, starting with the famous 15-minute weblog

noted briefly in Section 3.1, Rails 3 uses HTML5 by default (as indicated by the doctype ); since the HTML5 standard is new, some browsers (especially Internet Explorer) don’t yet fully support it, so we include some JavaScript code (known as an “HTML5 shiv”) to work around the issue: The somewhat odd syntax