Adding Real-Time To Your RESTful Rails App
JavaScript Ruby CoffeeScript
Latest commit ad124ee May 15, 2013 @liamks Merge pull request #1 from bdwain/master
fix javascript errors caused by an empty database
Permalink
Failed to load latest commit information.
app fix js errors caused by an empty db May 14, 2013
config first commit Feb 3, 2013
db first commit Feb 3, 2013
doc first commit Feb 3, 2013
lib updated readme file Feb 26, 2013
log first commit Feb 3, 2013
public first commit Feb 3, 2013
realtime updated readme file Feb 26, 2013
script first commit Feb 3, 2013
test first commit Feb 3, 2013
vendor first commit Feb 3, 2013
.gitignore updated readme file Feb 26, 2013
Gemfile first commit Feb 3, 2013
Gemfile.lock first commit Feb 3, 2013
README.md fix Feb 26, 2013
Rakefile first commit Feb 3, 2013
config.ru first commit Feb 3, 2013

README.md

Adding Real-Time To Your RESTful Rails App

This repository contains the code for both the Rails app, and the Node app, that accompanies the blog entry "Adding Real-Time To Your RESTful Rails App".

Steps I Took

Below are some of the steps I took, that were not outlined in the above blog entry. Make sure you have Redis installed and running!

rails new rails_realtime --database=postgresql
cd rails_realtime

rake db:create
rails generate scaffold Book title:string num_pages:integer
rake db:migrate

Add gem 'redis' and gem 'pg' to the Gemfile, then run bundle install.

Creating The Node.js App

mkdir realtime
cd realtime
echo 'Real-Time' > README.md

Then create package.json (see realtime/package.json for reference). From the realtime directory run npm install. In your Rails' .gitignore file add /realtime/node_modules to ignore the installed node modules.

The Backbone.js App

The Backbone.js application resides in app/assets/javascripts. application.js specificies the javascript files that comprise the web application and their load order. If you're building a real production app you may want to look into http://requirejs.org/ to manage your dependencies. app.js.coffee is the starting point for the Backbone.js application.

To Start The App

The Rails App: rails s

The Node App (from the realtime folder): node realtime-server.js

Done

Between the Blog, the code in this repository, and the above steps you should hopefully have the information necessary to add real-time to your Rails app!