O'Reilly logo

RailsSpace: Building a Social Networking Website with Ruby on Rails™ by Aurelius Prochazka, Michael Hartl

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Modeling users

Having a front page up and running is a good start, but now it’s time to get to the core of any social networking site: a database of registered users. In the process, we’ll experience the remarkable power of models—the M in MVC—which, perhaps more than anything else, sets Rails apart from other frameworks.

The purpose of this chapter is to build a User model to represent RailsSpace users, deciding which attributes (such as screen names, email addresses, etc.) we want them to have. The User model will rely on Active Record, a library for communicating between Ruby objects and relational databases. We’ll spend much of the chapter exploring Active Record using the console, which is essentially a command line for Rails. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required