Rails Routes in Javascript with js-routes

One thing that has annoyed me historically is hitting our Rails routes from Javascript. I’ve either sent the route down with other JSON data or simply typed the right string into the Javascript code. Both solutions work but I was never wild about them. Now we’ve been using the “js-routes”:https://github.com/railsware/js-routes library for a couple of months and it’s been working great. It’s easy to use: access the @documents@ resource with the Javascript function @Routes.documents_path()@. It takes parameters just like the Rails routes helpers.

Thank you to Bogdan Gusiev and the other contributors of the @js-routes@ library.