Agile Web Development with Rails

Start from the beginning
                                        

Prepared exclusively for Jordan A. Fowler

KEEPING UP-TO-DATE

3.7 Keeping Up-to-Date

AssumingyouinstalledRails usingRubyGems,keepingup-to-dateis relatively easy.Issue the command

dave> gem update rails --include-dependencies

andRubyGems willautomaticallyupdateyourRailsinstallation.The nexttime you startyour application,it willpick up thislatest version of Rails.(Wehave more to say about updatingyour applicationinproductionin the Deployment andScaling chapter, starting onpage 613.)RubyGemskeepsprevious versions of thelibrariesitinstalls.You candelete these with the command

dave> gem cleanup

Afterinstalling anewversionofRails,youmight alsowanttoupdatethe .les thatRailsinitially added toyour applications(theJavaScriptlibrariesit uses forAJAX support, various scripts, and so on).You cando thisby running the following commandinyour application�fs top-leveldirectory.

app> rake rails:update

3.8 Rails and ISPs

Ifyou�frelooking toput aRails application onlinein a sharedhosting environ-ment,you�fll need to .nd aRuby-savvyISP.LookforonethatsupportsRuby, has theRubydatabasedriversyou need, and offersFastCGI and/orLightTPD support. We�fll have more to say about deploying Rails applications in Chap-ter 27, Deployment and Production, onpage 613.

Thepagehttp://wiki.rubyonrails.com/rails/pages/RailsWebHosts ontheRails wikilists someRails-friendlyISPs.

Now that wehaveRailsinstalled,let�fs useit.On to the next chapter.

Report erratum

Prepared exclusively for Jordan A. Fowler

Chapter4

InstantGrati.cation

Let�fs write a simple applicationto verifywe�fvegotRails snuglyinstalled on our machines.Along the way, we�fllget apeek at the wayRails applications work.

4.1 Creating a New Application

Whenyouinstall theRailsframework,youalsoget anew command-linetool, rails, whichis used to construct each newRails application thatyou write.

Whydo we need a tool todo this.why can�ft wejusthack awayin ourfavorite editor, creating the source for our application from scratch? Well, we could just hack. After all, a Rails application is just Ruby source code. But Rails also does a lot of magic behind the curtain to get our applications to work with a minimum of explicit con.guration. To get this magic to work, Rails needsto .nd all thevariouscomponentsofyourapplication.Aswe�fll seelater (in Section 14.2, Directory Structure, on page 228), this means that we need to create a speci.c directory structure, slotting the code we write into the appropriate places. The rails command simply creates this directory structure for us andpopulatesit with some standardRails code.

To create your .rst Rails application, pop open a shell window, and navigate to a place in your .lesystem where you�fll want to create your application�fs directorystructure.In our example, we�fllbe creating ourprojectsin adirectory called work. In that directory, use the rails command to create an application called demo. Be slightly careful here.if you have an existing directory called demo,youwillbeasked whetheryouwanttooverwriteany existing.les.

dave> cd work

work> rails demo

create

create app/controllers

create app/helpers

create app/models

:::

Prepared exclusively for Jordan A. Fowler

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