Subscribe to my Feed, follow me on Twitter, recommend me on Working With Rails or see my code on GitHub
routes.js, episode two: The Plugin
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.
