Skip to Content
Ruby on Rails For Dummies®
book

Ruby on Rails For Dummies®

by Barry Burd
January 2007
Beginner
330 pages
6h 52m
English
Wiley
Content preview from Ruby on Rails For Dummies®

Chapter 9. Some Things You Can Do with Models

In This Chapter

  • Creating a Web site to store personal data

  • Viewing and modifying a Rails model

  • Programming for a model with Ruby

Here's a list of things that come in sets of three:

  • Stooges: Curly, Larry, Moe

  • The number of strikes until you're out: Strike one, Strike two, Strike three

  • Things that influence the price of a house: Location, Location, Location

  • Monkeys: See no evil, Hear no evil, Speak no evil

  • People involved in a love triangle: Person 1, Person 2, Person 1's best friend

  • Books in the Hitchhiker's Guide “trilogy”: Guide, Restaurant, Universe, Fish, Harmless

  • Items that would be in this list, if the list were more concise: Stooges, Strikes, Houses

  • Parts of the Rails framework: Model, View, Controller

In case you missed it, the last item in the list is the most relevant. Chapter 5 deals with the view and the controller. This chapter covers the model — the supreme item in the Rails triumvirate.

To make the discussion concrete, this chapter uses one big example — a Web site that stores photographs.

A Web Site for Photos

Here's my completely unoriginal idea: Create a Web site that displays photos. Initially, each photo entry has its own filename and its own description. The filename refers to an image file on a hard drive. (For example, niagara_falls.jpg may be a filename.) The description tells you something about the photo. (“Alan beats me up on our trip to Niagara Falls with Mom and Dad watching in the background.”)

Niagara Falls?

This chapter ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Ruby on Rails: Up and Running

Ruby on Rails: Up and Running

Bruce Tate, Curt Hibbs
Ruby on Rails® Bible

Ruby on Rails® Bible

Timothy Fisher
Learning Rails 5

Learning Rails 5

J. Mark Locklear, Eric J Gruber, Barnabas Bulpett

Publisher Resources

ISBN: 9780470081204Purchase book