Agile Web Development with Rails

Start from the beginning
                                        

It seems strange to be releasing a second edition at a time when the .rst edition is still among the best-selling programming books in the world. But Railshas changed, and we need to change thisbook withit.

Enjoy!

DaveThomas October 2006

Report erratum

Prepared exclusively for Jordan A. Fowler

Chapter1

Introduction

Ruby on Rails is a framework that makes it easier to develop, deploy, and maintain web applications.During the months thatfolloweditsinitial release, Rails went from being an unknown toy to being a worldwide phenomenon. It has won awards, and, moreimportant,ithasbecome theframeworkof choice for the implementation of a wide range of so-called Web 2.0 applications. It isn�ftjusttrendyamonghard-corehackers: many multinational companies are usingRails to create their web applications.

Whyis that?There seem tobe many reasons.

First, there seemed to be a large number of developers who were frustrated withthetechnologiesthey were usingto create web applications.Itdidn�ft seem to matter whether they were using Java, PHP, or .NET.there was a growing sense that theirjob wasjust too damnhard.And then, suddenly, along came Rails, andRailsis easier.

But easy onits owndoesn�ft cutit.We�fre talking aboutprofessionaldevelopers writing real-world web sites. They wanted to feel that the applications they were developing would stand the test of time.that they were designed and implemented using modern,professional techniques.So thesedevelopersdug intoRails anddiscoveredit wasn�ftjust a toolforhacking out sites.

For example, all Rails applications are implemented using the Model-View-Controller(MVC) architecture.Javadevelopers are used toframeworks such asTapestry andStruts, which arebased onMVC.ButRailstakesMVCfurther: when you develop in Rails, there�fs a place for each piece of code, and all the pieces of your application interact in a standard way. It�fs as if you start out with the skeleton of an application alreadyprepared.

Professionalprogrammers writetests.Andagain,Railsdelivers.AllRails appli-cations have testing support baked right in. As you add functionality to the

Prepared exclusively for Jordan A. Fowler

CHAPTER 1. INTRODUCTION

code,Rails automatically createstest stubsforthatfunctionality.Theframe-work makesit easytotest applications, and as a resultRails applicationstend toget tested.

Rails applications are written in Ruby, a modern, object-oriented scripting language.Rubyis concise withoutbeing unintelligiblyterse.you can express ideas naturallyand cleanlyinRuby code.Thisleadstoprogramsthat are easy to write and(just asimportantly) are easy to read monthslater.

Rails takes Ruby to the limit, extending it in novel ways that make a pro-grammer�fs life easier. This makes our programs shorter and more readable. It also allows us to perform tasks that would normally be done in external con.guration .lesinsidethecodebaseinstead.Thismakesitfareasierto see what�fs happening. The following code de.nes the model class for a project. Don�ftworry aboutthedetailsfor now.Instead,justthinkabouthowmuch informationisbeing expressedin afewlines of code.

class Project < ActiveRecord::Base

belongs_to :portfolio

has_one :project_manager

has_many :milestones

has_many :deliverables, :through => :milestones

validates_presence_of :name, :description

You've reached the end of published parts.

⏰ Last updated: Mar 22, 2008 ⏰

Add this story to your Library to get notified about new parts!

Agile Web Development with RailsWhere stories live. Discover now