Followers and Following

In order to get someone a timeline in JotRod, we need followers and following lists to compile the Jots from. This means that we need to add a new ColumnFamily called Followers and another one called Following. We don't have the joins capability from relational databases to do this for us. I'm going to hijack the User model's database connection to create the ColumnFamilies. (We don't have migrations, yet.) Here's what I ran in the rails console:

cf\_def = =\> "JotRod", :name =\> "Followers") User.connection.add\_column\_family(cf\_def) cf\_def = =\> "JotRod", :name =\> "Following") User.connection.add\_column\_family(cf\_def)

Now that we have the ColumnFamilies, I want to have syntax like this to define the relationships on the User model:

list :followers, :User list :following, :User

This should provide the following API: #followers - returns an array of users as specified from the Followers ColumnFamily #followers<<(user)  - adds the user to the User object's followers list if it's not already there and a similar API for following.Sandra's repositoryJotRod's repositoryDownload 680 MBDownload (iPod & iPhone) 165 MBTake the 2011 Readers Survey

Sign up for the Newsletter

Join our newsletter and get updates in your inbox. We won’t spam you and we respect your privacy.