Showing posts with label a social network in rails. Show all posts
Showing posts with label a social network in rails. Show all posts

A Social Network in Rails: 5-minute setup with RVM and Railsbricks

+


This post is part of an ongoing feature about creating a social network in Rails.

Here we'll set up the Rails app for our photo social network, codenamed Piccy.
No fumbling around with different ruby version managers and complex Rails setups: RVM + Railsbricks, done in 5 minutes:

A Social Network in Rails: Comments

This post is part of an ongoing feature about creating a social network in Rails.

This time, we're adding comments to our Photo model, as presented in the elegant permalinks post. First of all, I looked for a gem to do this job for us, and found acts_as_commentable. Its setup goes something like this:

Add the gem to our Gemfile, and run `bundle install`:
gem 'acts_as_commentable'
Generate the tables and migrate the DB:
$ rails g comment
$ rake db:migrate
Add the comments to our Photo model:
class Photo < ActiveRecord::Base
  acts_as_commentable
end
By doing this, we get the following interface to the comments in our photos:

A Social Network in Rails: Activity Feed

This post is part of an ongoing feature about creating a social network in Rails. You can see part 1 here, about creating elegant permalinks for your content.

Today I'm presenting a wonderful gem called public_activity , which lets you create activity feeds with a few lines of code:
To begin with, add the gem to your Gemfile, as usual:
gem "public_activity"

A Social Network in Rails: Elegant permalinks


In this post we're adding permalinks to a Rails app using the friendly_id gem.

Let's say you have a `User` and a `Photo` model in your app, and a user has_many :photos.
To add a permalink to a photo post that looks like this:
www.nice-pics.com/berners-lee/photos/my-first-site



Add friendly_id to your Gemfile:
gem "friendly_id"
Add the permalink schema to your routes.rb:
get ":user_id/photos/:photo_id", to: "photos#show", as: :photo_permalink
Now, add the friendly_id scheme to your User:

A Social Network in Rails: a gem-by-gem guide


  1. 5-minute Setup with RVM and Railsbricks
  2. Elegant permalinks
  3. Activity Feed
  4. Comments
  5. Notifications (coming soon)
  6. Follow/mention people (coming soon)
  7. ...
I'm compiling and expanding these blog posts into a book via Leanpub, A Social Network in Rails, subscribe to be updated of its progress here.