Skip to Main Content
Learning Rails
book

Learning Rails

by Simon St. Laurent, Edd Dumbill
November 2008
Beginner content levelBeginner
448 pages
12h 25m
English
O'Reilly Media, Inc.
Content preview from Learning Rails

Chapter 2. Rails on the Web

Now that you have Rails installed (or have signed into Heroku), it’s time to make Rails do something—not necessarily very much yet, but enough to show you what happens when you make a call to a Rails application, and enough to let you do something to respond when those calls come in. There’s a long tradition in computer books of starting out with a program that says “hello” to the programmer. We’ll follow that tradition and pursue it a bit further to make clear how Rails can work with HTML. You’re welcome, of course, to make Rails say whatever you’d like.

Note

The work in this chapter depends on the hello application created in Chapter 1. If you didn’t create one, go back and explore the directions given there. If you’re working with Heroku, any new application will do. You can also find the files for the first demonstration in ch02/hello001 of the downloadable code.

Creating Your Own View

Saying “hello” is a simple thing, focused exclusively on putting a message on a screen. To get started, we can post that message using a view including HTML that will get sent to the browser.

Rails actually won’t let you create views directly. Its controller-centric perspective requires that views be associated with controllers. While that might seem like a bit of an imposition, it’s not too hard to work around.

Creating anything in Rails requires going to the command line:

  • In Instant Rails, you’ll want to click the “I” on the main Instant Rails dialog box again, and choose ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Rails 5

Learning Rails 5

J. Mark Locklear, Eric J Gruber, Barnabas Bulpett
Mastering Ruby Closures

Mastering Ruby Closures

Benjamin Tan Wei Hao
Ruby on Rails® Bible

Ruby on Rails® Bible

Timothy Fisher

Publisher Resources

ISBN: 9780596154943Supplemental ContentErrata