Easily setup and use batman.js (0.15) with Rails 4
Add this line to your application's Gemfile:
gem 'batman-rails'
And then execute:
$ bundle
$ rails generate batman:app
Running rails generate batman:app
will create the following directory structure under app/assets/app_name/
:
models/
views/
controllers/
html/
lib/
It will also create a toplevel app_name.coffee
file to setup namespacing and setup initial requires.
Batman-Rails provides 3 simple generators to help get you started using Batman.js with Rails. The generators will only create client side code (CoffeeScript).
rails generate batman:model
This generator creates a batman model inside app/assets/app_name/models
to be used to talk to the Rails backend.
rails generate batman:controller
This generator creates a batman controller for the given actions provided.
rails generate batman:scaffold
This generator creates a controller, helper and model to create a simple crud single page app
Created a new Rails application called blog
.
rails new blog
Edit your Gemfile and add
gem 'batman-rails'
Install the gem and generate scaffolding.
bundle install
rails generate batman:app
rails generate scaffold Post title:string content:string
rake db:migrate
rails generate batman:scaffold Post title:string content:string
You now have installed the batman-rails
gem, setup a default directory structure for your frontend batman code. Then you generated the usual Rails server side scaffolding and finally generated Batman.js code to provide a simple single page app.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request