Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cloning Internet Applications with Ruby

You're reading from   Cloning Internet Applications with Ruby Make clones of some of the best applications on the Web using the dynamic and object-oriented features of Ruby

Arrow left icon
Product type Paperback
Published in Aug 2010
Publisher Packt
ISBN-13 9781849511063
Length 336 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Chang Sau Sheong Chang Sau Sheong
Author Profile Icon Chang Sau Sheong
Chang Sau Sheong
Arrow right icon
View More author details
Toc

Building the clone


Now that we are done with the discussions on Twitter, its features and also the design of the clone, let's roll up our sleeves and get into the act of building it.

Modeling the data

The data model for Tweetclone is quite simple; it consists of two major classes—User and Status, and two minor classes that describe the relationships—Relationship and Mention.

The Relationship class defines the many-to-many relationship between users, that is it defines who follows whom. The Mention class defines the many-to-many relationship between users and statuses (aka tweets). Each status can mention one or more users and each user can be mentioned in one or more statuses. A user can have one or more statuses, while only one user can be the recipient of a status. In addition to that, because we're modeling direct messages with statuses, a user can also have one or more direct messages.

In Tweetclone we have placed all the models in a single file called models.rb.

User

Let's define the User...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image