Build Your Own Ruby on Rails Web Applications
Format: PDF / Kindle (mobi) / ePub
Want to learn all about Ruby on Rails, the web application framework that is inspiring developers around the world?
This practical hands-on guide for first-time Ruby on Rails programmers will walk you through installing the required software on a Windows, Mac or Linux computer. And before you get coding, an entire chapter is devoted to object oriented programming in Ruby, so you'll be completely confident with the Ruby language before you begin working with Rails.
The example application that the book builds - a user-generated news web site - is built upon with each following chapter, and concepts such as sessions, cookies and basic AJAX usage are gradually introduced. Different aspects of Rails, such as ActiveRecord, migrations and automated testing are explored with each feature that is added to the application.
The book finishes with chapters on debugging, benchmarking and deployment to a live web server.
By the end of the book, you'll have built a fully-featured Web 2.0 application and deployed it to the Web. And all code is up-to-date for Rails 1.2, so you can begin coding immediately with the latest version of Rails.
1.8.4, you’ll find that elements of the section covering breakpoints in Chapter 11 simply won’t work! The problem is caused by the fact that the proper working of the breakpoint library packaged with Rails is reliant on a bug in Ruby. This bug was patched in Ruby 1.8.5, so breakpoint stopped working. We hope that the problem will be resolved soon, but in the meantime you’ll be fine if you stick with Ruby 1.8.4. Feel free to skip the sections that relate to operating systems other than yours, and
[http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html]. 3 http://rubyforge.org/frs/download.php/9957/InstantRails-1.3a-win.zip 4 http://rubyforge.org/frs/?group_id=904 5 I’m recommending you use InstantRails 1.3a, rather than 1.4 or newer, due to the previously mentioned problem with Ruby 1.8.5 and Rails’s included breakpoint library. The newer versions of InstantRails ship with Ruby 1.8.5, and the Ruby on Rails download page recommends Ruby 1.8.5. However, if you choose to install Ruby
different kind of car. Instead of the regular four wheels that standard Car objects have, this one would have six wheels (stored in the class variable @@wheels). It would also have extra functionality, made possible by an extra method—turn_on_television— which would be available to be called by other objects. However, if we were to instantiate a regular Car object, the car would have only four wheels, and there would be no instance method for turning on an on-board television. Think of
data for each environment in entirely separate databases. So at any given time, you might have: ❑ live data with which real users are interacting in the production environment ❑ a partial copy of this live data that you’re using to debug an error or develop new features in the development environment ❑ a set of testing data that’s constantly being reloaded into the testing environment Let’s look at how we can configure our database for each of these environments. 90 Database Configuration
'Hello World from Ruby!' %> There are two forms of the ERb tag pair: one that includes the equal sign, and one that does not: <%= … %> This tag pair is for regular output. The output of a Ruby expression between these tags will be displayed in the browser. <% … %> This tag pair is for code that is not intended to be displayed, such as calculations, loops, or variable assignments. An example of each is shown below: <%= 'This line is displayed in the browser' %> <% 'This line executes