Every Batman.js app on Rails needs a sidekick. Bring realtime to the fight with Robin.js.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
vendor/assets/javascripts/robin
.gitignore
.travis.yml
Gemfile
Guardfile
LICENSE.txt
README.md
Rakefile
robin-rails.gemspec

README.md

Gem Version Dependency Status Code Climate Coverage Status Build Status

Robin.js on Rails

Every Batman.js app on Rails needs a sidekick. Bring realtime to the fight with Robin.js.

Usage

For client-side info on Robin.js, checkout the CoffeeScript source.

Vendoring

The latest version of the client-side Robin.js source is available through the asset pipeline under the robin namespace.

# app/assets/javascripts/application.js.coffee
#
#= require batman/es5-shim
#= require batman/batman
#= require batman/batman.rails
#= require batman/batman.jquery
#
#= require robin/robin

Make sure you load Robin after the Batman source files. To get things working on the frontend, checkout the setup details for Robin.js.

Realtime

The easiest way to get started is to add Robin to your Gemfile:

gem 'robin-rails' # Robin.js vendor and Rails events
gem 'faye' # websocket backend

For every model you want to update in realtime, include the Robin::Rails module.

class Post < ActiveRecord::Base
  include Robin::Rails
end

You can configure the Faye endpoint in an initializer.

# config/initializers/robin.rb
Robin.configure do |config|
  config.faye_url = 'http://localhost:9292/faye' # the default
end

That's it! Anytime a record is created, updated, or destroyed, the event will immediately be pushed to Robin.js subscribers via Faye. If you've got Faye running correctly (e.g. make sure you use Thin or another EventMachine friendly server), you should now be able to open several browser clients, edit models in the JS console, then watch the events propagate to other subscribed clients!

Contributing

This project is (obviously) in its infancy with just the basics. TODO lists a bunch of features I hope to get implemented, but this is GitHub: if you add a feature on your own, give me a hand and contribute!

No guidelines yet other than your basics: fork it, submit a pull request with relevant tests, and try to follow the conventions already in the code. Any and all quality contributions welcome!