Skip to content
a real time implementation of a basic Rails+Batman.js crud app
JavaScript Ruby CoffeeScript CSS
Find file
Latest commit 005a57f Feb 12, 2014 @zhubert Merge pull request #1 from Domon/fix-comment-destroy-redirection
Fix redirection errors after destroying comments
Failed to load latest commit information.
app
config
db
doc
extras/fancy_batman_app
lib
log
public
script
test
vendor
.gitignore
Gemfile
Gemfile.lock
LICENSE.txt
Procfile
Procfile.pow
README.md
Rakefile
config.ru

README.md

Fancy App

Batman, Rails, Bootstrap app, plus real time updates via Pusher.

Install

bundle
rake db:reboot # sets everything up

Configuration

You'll need to setup an account on Pusher and have the right environment variables specified. Create .env

PUSHER_APPID=12345
PUSHER_KEY=1234567890
PUSHER_SECRET=1234567890

If you use pow, also create a .powenv

export $(cat .env)

Batman Components

There are two ways real time updates get to Batman: Batman Pusher (dubbed multiplayer) and BatchedRailsStorage (single player)

  • BatmanPusher - connects the browser to Pusher for real time updates
  • BatchedRailsStorage - a storage module that takes the batch included inline with the request and feeds it to ModelUpdater
  • ModelUpdater - parses the real time updates from BatmanPusher and updates the Batman models, which then update the view bindings

Rails Components

  • ApplicationController hooks - for starting DirtyTracker, overriding render to include a batch inline (single player), and calling the publish method of DirtyTracker (multiplayer)
  • DirtyTracker - this is a Rails-side component that keeps track of changes on all the models you designate. It has some logic to package the changes up in a way the ModelUpdater understands
  • PusherWorker/PusherBatchWorker - a duo that can be used for asynchronous transmission of updates
Something went wrong with that request. Please try again.