Route helpers in JS/CS assets

No pressure at all :) I'm using a patched version of js-routes right

now:

[https://github.com/railsware/js-routes/pull/46](https://github.com/railsware/js-routes/pull/46)



I'd certainly appreciate your effort on that, but I'd just like to

advice you on thinking about the solution in the Rails side first as I guess this is the hardest part.

You can take a look at the js-routes source code to have some ideas

though.

I’ve not had very much time on this, so sorry for the delay. I’ve knocked together a repository and a gist to explain what I’m suggesting. If you want to add a pull request with any failing tests, I’ll try and get them passing.

To recap, I’m imagining this sits as a library that is added to coffee-rails, that CoffeeScript is populated with reserved methods matching the names of the routes, and when one is encountered it calls the parse method to convert it to more CS or JS. I’m making assumptions about how CS does stuff and I think that should be the next piece of investigation.

However, this is basically how I’d approach from the Rails side of things. It’s extremely simple…

https://gist.github.com/2882545

https://github.com/ihid/rails-coffeescript-routes

Your thoughts/feedback are welcome :slight_smile:

Great, Jeremy. I’ll take a look at it when I find some free time. But I guess this approach won’t work for routes with constraints like /\d+/, but maybe the format method you’re using won’t check for constraints…

Cheers,

Rodrigo.