I am available for freelance work! Click here to email me.

Building a Social Network Site in Rails

April 25th, 2008

I’m not going to cover how to actually code an entire social network site in rails as all social network sites vary in their functionality (and it’ll take too long). I will cover plugins and other things you might find useful though.

Quick Start

If you don’t really want to do the coding but want to get a site up and running and soon as possible, you may want to have a look at Lovd by Less by the guys over at Less Everything. Lovd by Less contains user signups, galleries, blogs, comments and various other things that you might want, so it’s a great starting block for your site.

Social Network Plugins

Here’s a list of plugins that I’ve found to be useful while coding my own social networking site:

Restful Authentication

RESTful Authentication is pretty much the defacto standard for user authentication in rails. It allows easily set up user signups, login functionality and email notifications. The plugin doesn’t set up thing’s like forgotten password functionality but there is a great tutorial over Rails Forum.

# To Install
ruby script/plugin source http://svn.techno-weenie.net/projects/plugins
ruby script/plugin install restful_authentication
Paperclip

Paperclip is a brilliant plugin by Jon Yurek over at ThoughtBot. Paperclip is used for managing file uploads and attaching the files to models. You can read more over at my article: Paperclip: Attaching Files in Rails.

# To Install
svn export https://svn.thoughtbot.com/plugins/paperclip/tags/rel_2-0-2
piston import https://svn.thoughtbot.com/plugins/paperclip/trunk
Will_paginate

Will paginate is a great plugin for allowing paging of your records. Paging is a pain in the ass, but will_paginate makes it easy as pie.

# To Install
ruby script/plugin install svn://errtheblog.com/svn/plugins/will_paginate
Acts_as_slugable

Acts_as_slugable takes the pain out of generating URL slugs. Everyone prefers meaningful URLs, so instead of showing a users page with ‘/users/231′, you can use ‘/users/jim-neath’. Nice.

# To Install
ruby script/plugin install http://code.dunae.ca/acts_as_slugable
White_list

White_list is yet another brilliant from Techno Weenie. The white_list helper will html encode all tags and strip all attributes that aren’t specifically allowed. It also strips href/src tags with invalid protocols, like javascript: especially. It does its best to counter any tricks that hackers may use, like throwing in unicode/ascii/hex values to get past the javascript: filters.

# To Install
ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/white_list/
Acts_as_commentable

Acts_as_commentable allows you to add comments to your models. It takes care of all the polymorphic associations for you, which is nice.

# To Install
ruby script/plugin install http://juixe.com/svn/acts_as_commentable
ReCAPTCHA

Fucking captchas. Unfortunately a necessary evil. If you’re going to use captchas then you might as well help to digitalise books. The reCAPTCHA plugin utilises the reCAPTCHA service which digitalises books by making users input the text.

# To Install
ruby script/plugin install svn.ambethia.com/pub/rails/plugins/recaptcha/
Acts_as_taggable_on_steroids

Everybody loves tagging, surely? Tag pictures, videos, blog posts, whatever you want. Acts_as_taggable_on_steroids is a great plugin for allowing your users to tag their stuff. It allows tag clouds and all that web 2.0 jazz everyone seems to love.

# To Install
ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids
Exception Notifier

Exception Notifier is a must have. It emails you when your live application fails. No matter how much testing you do, no doubt there’s going to be a scenario where it fails and when that happens you want to know.

# To Install
ruby script/plugin install exception_notification
Throttler

This is one of my favourite plugins. Say your site get’s slashdotted of dugg and you end up with immense traffic, the main thing is to keep your site up and running. This is where throttler comes in. You can throttle certain actions on your site when your server load is above a certain level. So you could disable video uploads while your server load is above x to prevent your server from crumbling.

# To Install
ruby script/plugin install http://svn.kabisa.nl/rails/plugins/throttler
Backup_fu

You’ve been working on your social network site for months and finally the traffic is coming in and you have a decent user base. Then one day your server dies and you lose all your data. Woe is you. You should have backed up. Using Backup_fu you can automatically backup your database and files to Amazon S3.

# To Install
sudo gem install aws-s3
ruby script/plugin install http://backup-fu.googlecode.com/svn/backup_fu/
Fischy Friends

Fischy_friends is a plugin by Daniel Fischer. It’s a great starting point for a friends system. I’ve used it on a couple of my own projects and it’s worked great for me.

# Github
http://github.com/dfischer/fischyfriends/tree/master

Other Useful Tools

SWFUpload

I love SWFUpload. It uses a small flash file to allow users to upload multiple files at once. The front end is completely open and coded in javascript so you can customise it how you like. You can see the demos here.

Download: http://swfupload.googlecode.com/files/SWFUpload%20v2.0.2.Release.zip

TinyMCE Text Editor

TinyMCE is WYSIWYG editor coded entirely in javascript. It’s useful for the less techno savvy of your users (which will no doubt be most). There’s a whole load of plugins available for the editor so it’s highly extensible.

Download: http://prdownloads.sourceforge.net/tinymce/tinymce_3_0_7.zip?download

FFMPEG/Mencoder

FFMPEG is a command line utility to convert various formats of video into other formats. The main use you’ll want to use this for is to convert videos into flv files for use with a flash video player.

JW FLV Media Player

The JW FLV Media Player (built with Adobe’s Flash) is an easy and flexible way to add video and audio to your website. It supports playback of any format the Adobe Flash Player can handle (FLV, but also MP3, H264, SWF, JPG, PNG and GIF). It also supports RTMP and HTTP (Lighttpd) streaming, RSS, XSPF and ASX playlists, a wide range of flashvars (variables), an extensive javascript API and accessibility features.

Rails Hosting

Once you’ve got your wonderful social network finished, you’re going to want somewhere to host the beast.

I highly recommend checking out Brightbox for all your hosting needs. They offer affordable servers complete with Five Runs.

Books

RailsSpace: Building a Social Networking Website with Ruby on Rails

“Ruby on Rails is fast displacing PHP, ASP, and J2EE as the development framework of choice for discriminating programmers, thanks to its elegant design and emphasis on practical results. RailsSpace teaches you to build large-scale projects with Rails by developing a real-world application: a social networking website like MySpace, Facebook, or Friendster.

Inside, the authors walk you step by step from the creation of the site’s virtually static front page, through user registration and authentication, and into a highly dynamic site, complete with user profiles, image upload, email, blogs, full-text and geographical search, and a friendship request system. In the process, you learn how Rails helps you control code complexity with the model-view-controller (MVC) architecture, abstraction layers, automated testing, and code refactoring, allowing you to scale up to a large project even with a small number of developers.

This essential introduction to Rails provides

  • A tutorial approach that allows you to experience Rails as it is actually used
  • A solid foundation for creating any login-based website in Rails
  • Coverage of newer and more advanced Rails features, such as form generators, REST, and Ajax (including RJS)
  • A thorough and integrated introduction to automated testing

The book’s companion website provides the application source code, a blog with follow-up articles, narrated screencasts, and a working version of the RailSpace social network.”

(Possibly) Related Posts

Recommend Me

If you found this post or anything else on this site of any use, then please take the time to recommend me on Working with Rails.

You can follow any responses to this entry through the RSS 2.0 feed. Trackback from your own site.

  • Thanks for the share. Came across really very useful plugins and I was not aware of most of them. Nice sharing of very useful links. Worth reading.
  • As one of the Rails programming enthusiast, this will help me a lot especially the codes are given. What I need to do now is to analyze the code and to make sure that I'm on the right track while doing the programming. Thanks for sharing the code.
  • As a Rails newbie, really appreciated the collection of plugins and tools! Thanks :)
  • It was a very interesting code indeed and this will really refresh my skills.
  • Thank you for sharing the codes. I guess I still need to refresh my programming and web development skills by reading more about this.
  • Thank you for sharing the codes. This will help a lot.
  • Ruby on rails quite used infrastructure to develop a website and i am very thank full to you that you spend your valuable time to update information about Ruby on Rails
  • Thanks for posting this.
    Is there any plan to make this the standard development cycle?
  • mfarney
    I have a question about websites. What's the difference between all these programming languages used to build sites? Why would a ruby on rails site be better than the classic html or the xml?
    _____________
    Mathew Farney - Web Hosting
  • staffing1
    Great work, nice post.I am using a lot of the same on my project. Thanks for the post!
    www.staffingpower.com
  • Nice list, I am going to have to try some of these out. I have used acts_as_authenticated, which I like, but I am going to have to make the move to restful_authentication very soon. As for the others, I just need to think of the right project for them (hmm..., a blog maybe ;-) )
  • Hail
    Hi does anyone know where I can get some webcam function plugins, I want to start a webcam adult site. I need a plugin that lets my models set up their webcam and I need a plugin that has the pay system function so we both get paid.
  • Awesome list, Thanks for socializing me :)
  • Thanks for this great list and your other articles--I've been frequenting your site over the last few weeks. Just wondering if anyone knows of a good plugin that would help with tracking user activities across several models, like "Aaron added a bookmark to foo.com" and "Jane left a comment in the 'What's everyone want for dinner?' topic," etc.

    Thanks,
    Aaron
  • Thanks for the list, might use some in my next project. For those pesky thumbnails I used RMagick and jsCropper. Check out the latter at http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/.
  • What a great list! If I had it some months ago... In my current social networks projects I also include acts_as_taggable_on_steroids for the tags, ultrasphinx for the searches, and ar_mailer and simplified_starling for long-processing jobs like sending emails to thousands of users in background.
  • Any comments on http://www.lovdbyless.com vs. http://insoshi.com/? Thanks.
  • Mr. Bless
    Great work.
  • Hi Dan,

    As much as I would love to, I'm currently up to my eyeballs in work, so alas do not have the time.

    I hope you find someone. You could always try looking into Lovd By Less

    - Jim
  • Dan Castro
    This is for Jim Neath.

    I'm looking for someone with lots of experience using Ruby on Rails to create a social networking site from scratch.

    Would you be interested in giving us a bid?

    Please contact me privately at danmancastro@gmail.com

    Thanks,
    Dan Castro
    Austin, Texas
    512-732-0111
  • @Matthew - I added those plugins for people who don't want to spend the time writing code that's already available.

    Acts_as_commentable is useful for people who don't really understand how to use polymorphic associations and the like.

    Acts_as_slugable is good for people who hate/suck at regex.

    @Martin - preference_fu sounds like a decent plugin. Will read up about it and add it to the list with a couple of other plugins I forgot to add with the original post.
  • nice post! our plugin list is nearly the same :) a plugin I would suggest is preference_fu (if you want to store many boolean settings like which notification a user wants to receive)
  • Some of these plugins confuse me. Actsascommentable, actassluggable. Why would I want plugins for code I can write myself in five minutes. I hate black boxes of stuff I don't have as much control over. Even will_paginate bugs me right now, but that more because they converted over to a gem and I have yet to understand how to hack it in that format.
  • I would also recommend restful acl plugin ( http://github.com/mdarby/restful_acl/wikis ) that is extrends the aforementioned Restful Authentication.
  • Check out ActsAsNetwork. Its a plugin that drastically simplifies the storage and manipulation of bidirectional "friend" relationships that naturally occur in social networks. http://actsasnetwork.rubyforge.org/
  • Nice list, I am going to have to try some of these out. I have used acts_as_authenticated, which I like, but I am going to have to make the move to restful_authentication very soon. As for the others, I just need to think of the right project for them (hmm..., a blog maybe ;-) )
  • Marco
    social network sites seem to be the only things you can do with rails ...
  • permalink_fu is another great plugin for generating permalinks. I've found it to be a bit easier to use than acts_as_sluggable. Here's its github page: http://github.com/technoweenie/permalink_fu
  • Looks like everyone is moving away from .NET :)

    You guys should check out Jacques Crockers Acts as .NET plugin :)
  • lol ... i might as well join the party and mention: i *DID* move away from .NET and to Rails :)

    Great List!!
  • Jonathan
    Thanks Jim for the fantastic list. Very helpful.

    @Luke - I too am trying to move my development team away from .NET and onto Rails :)
  • lukehartman
    Jim,

    Thanks for pooling these in once place. I'm about to teach some coworkers Rails so we can migrate away from .NET. I appreciate you putting this together.
  • bhauff
    Looks like a great list. I am using a lot of the same on my project. Thanks for the blog!
  • Mike Breen
    +1 for SWFUpload. We just implemented it on a .NET project because the available .NET components blow.

    Good post. it's nice to have these plugins all in one place. Thanks.
blog comments powered by Disqus
Purify - Issue Tracker

Jim Neath is a 26 year old Freelance Ruby on Rails developer from Manchester, UK.

Recommend Me

Categories