Skip to content

Instantly share code, notes, and snippets.

@lightyrs
Created January 2, 2012 21:01
Show Gist options
  • Save lightyrs/1552107 to your computer and use it in GitHub Desktop.
Save lightyrs/1552107 to your computer and use it in GitHub Desktop.
Rails Backbone Router Helper
# application_helper.rb
def backbone_router(resource, collection)
<<-eos
$(function() {
window.router = new #{APP_NAME.capitalize}.Routers.#{resource.capitalize}Router({#{resource.downcase}:#{collection.to_json.html_safe}});
Backbone.history.start();
});
eos
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment