ONLamp.com
oreilly.comSafari Books Online.Conferences.

advertisement


What Is Ruby on Rails

by Curt Hibbs
10/13/2005
Ruby on Rails
Ruby on Rails is a web application framework written in Ruby, a dynamically typed programming language similar to Python, Smalltalk, and Perl.

In This Article:

  1. High productivity and reduced development time
  2. How does Rails do it?
  3. Rails components
  4. General features
  5. Active Record
  6. Action Pack
  7. Action Mailer
  8. Action Web Service
  9. Parting thoughts

It has been just over a year since the public debut of Ruby on Rails on July 25, 2004. In this short time, Rails has progressed from an already impressive version 0.5 to an awe-inspiring, soon-to-be-released version 1.0 that managed to retain its ease of use and high productivity while adding a mind-boggling array of new features. This article introduces the components of the upcoming Ruby on Rails 1.0 and shows you what the fuss is all about.

I don't intend to teach you how to use Rails to write web applications. For that, you probably ought to start with Rolling with Ruby on Rails Revisited and Rolling with Ruby on Rails Revisited, Part Two. This is an introduction and road map to the many features of Rails.

High Productivity and Reduced Development Time

At the feature level, Ruby on Rails doesn't offer anything new. Existing web application frameworks have done it all before. What's the big deal, then? The difference lies in how Ruby on Rails does it. When you can finish simple web apps in days instead of weeks and more complicated web apps in weeks instead of months, people notice!

This newfound attention would be short-lived if the resulting web apps were messy and hard to maintain or extend. Fortunately Ruby on Rails actually facilitates good programming practices, which leads to well-factored and easily maintained code.

Related Reading

RJS Templates for Rails
By Cody Fauser


Read Online--Safari Search this book on Safari:
 

Code Fragments only

The attention would also be short-lived if Ruby on Rails had no depth--that is, if once you tried to use it for anything beyond the simplest of web applications, you suddenly found yourself hitting a wall, unable to proceed due to inherent limitations. Experienced developers who know their way around the Web have repeatedly reported that this is not the case with Rails. For example, Tomcat, Ant, and the Servlet API author James Duncan Davidson recently wrote:

Rails is the most well thought-out web development framework I've ever used. And that's in a decade of doing web applications for a living. I've built my own frameworks, helped develop the Servlet API, and have created more than a few web servers from scratch. Nobody has done it like this before. That's not to say they got it all right. It's by no means "perfect". I've got more than a few nits and picks about how things are put together. But "perfect" isn't the point. The point is that it gets you up and going fast and has plenty of depth to keep you going. And Rails does that very well.

It may be hard to believe that this is possible without a significant downside. Fortunately, you don't have to take my word for it (or anyone else's). You can easily prove it to yourself in a day or less by going through a Ruby on Rails tutorial and then developing a modest web application of your own choosing. After all, seeing is believing! If you don't want see yourself be amazingly productive, you can always watch someone else do it in the new Rails video.

How Does Rails Do It?

Like a good recipe, Rails helps you achieve this new level of productivity by combining the right ingredients in the right amounts. Here are a few of the most important ingredients that make Rails what it is.

Ruby

Much of the power of Rails comes from the Ruby programming language. Ruby's unique design makes it easy to create domain-specific languages and to do metaprogramming. Rails takes full advantage of this.

Full-stack MVC framework

Rails is an MVC (model, view, controller) framework where Rails provides all the layers and they work together seamlessly. Other frameworks often implement only part of the solution, requiring the developer to integrate multiple frameworks into the application and then coerce them into working together. (For example, a Java developer might use Hibernate, Struts, and Tiles to get full MVC support.)

Convention over configuration

Convention over configuration means an end to verbose XML configuration files--in Rails, there aren't any! Instead of XML sit-ups, a Rails application uses a few simple programming conventions that allow it to figure everything out through reflection and discovery. For example, Rails uses intelligent reflection to automatically map database tables to Ruby objects. Your application code and your running database already contain everything Rails needs to know.

Less code

Following the simple Rails programming conventions does more than just eliminate the need for configuration files. It also means that Rails can automatically handle myriad lower-level details without you having to tell it to do so. This means that you write fewer lines of code to implement your application. Keeping your code small means faster development and fewer bugs, which makes your code easier to understand, maintain, and enhance.

Generators

Rails' use of runtime reflection and metaprogramming eliminates much of the boilerplate code that you would otherwise have to create. You can often avoid what little boilerplate code remains by using the built-in generator scripts to create it for you. This leaves you with more time to concentrate on the code that really matters--your business logic.

Zero turnaround time

The typical development cycle for testing a change to a web app has steps such as configure, compile, deploy, reset, and test. This is very time consuming. The Rails development environment has none of this. You simply make a change and see it work. Don't make the mistake of dismissing this as a minor point. It's hard to overstate how much this improves productivity and helps you maintain a creative flow without interruption.

Scaffolding

Rails can automatically create a full set of CRUD (Create, Retrieve, Update, and Delete) operations and views on any database table. This scaffolding can get you up and running quickly with manipulating your database tables. Over time, you can incrementally replace the generated CRUD operations and views with your own--presumably much prettier and more functional.

Pages: 1, 2, 3, 4, 5, 6, 7

Next Pagearrow





Sponsored by: