Sneaky Abstractions

Subscribe to my Feed, follow me on , recommend me on Working With Rails or see my code on GitHub

routes.js, episode two: The Plugin

Posted on June 29, 2007 16:50 Tagged with routes, javascript, plugin, rails.

Now with all routes created equal (not just named routes anymore).

It turns out replicating Rails’ route generation in JavaScript wasn’t trivial, but it was definitely doable and it seems to work pretty well too. I’ve packaged it up in a plugin for easy consumption. Read more about it here.

Routes.generate({controller:'foo', action:'bar', id:'baz'})
Routes.page(1)
Routes.blog_entry_comment(1, 2)
Routes.page({id:42}, {onlyPath:true, escape:false})
Routes.generate({controller:'rabbits', rabid:'yes'})

You can test the route generation “live” here, or if you have FireBug installed, just use that.

Super Disco Breakin