RailsSpace: Building a Social Networking Website with Ruby on Rails™
by Michael Hartl, Aurelius Prochazka
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. ...
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