To my knowledge, batman.js is not maintained. For that reason, I don't suggest that you use it for a new project!
Adding Batman.js to an Existing Rails App
I was already using ActiveModel::Serializer to serve JSON from my app. To get Batman on the scene, I included
batman-rails in my Gemfile and installed it:
$ bundle install
The batman-rails gem comes with a generator to get everything in order.
I ran it and restarted my Rails server:
$ rails g batman:app # that's not _your_ app name, it's just "app"$ powder restart # restart your Rails server one way or another
I visited my app’s root_url and found Batman-rails landing page. How’d it get there!? Sure enough, the Batman generator had added a punchy line to the top of my routes file:
Along with that, there was a new file in my app/views/layouts folder, and then of course, app/assets/batman.
My first view
I didn’t want the Batman landing page at my root_url, I wanted a list of sounds! So, I ran a Batman generator, beefed up the model and controller, created the index html, and redefined the route:
classLang.SoundextendsBatman.Model@resourceName: 'sounds'@storageKey: 'sounds'@persistBatman.RailsStorage# Use @encode to tell batman.js which properties Rails will send back with its JSON.@encode'letter'@encodeTimestamps()