I'm having trouble getting this to work.
I have a Rails v4.1.0.rc1 app with an application namespace and an admin namespace, so I want to generate AppRoutes and AdminRoutes.
I use js-routes v0.9.7 and this is my initializer (just the AdminRoutes for now)
Should I then use = require js-routes or = require admin_routes?
= require js-routes
= require admin_routes
When I use = require js-routes, AdminRoutes is undefined and Routes contains all routes, not just the admin ones: http://screencast.com/t/uKGKH945aT0n
When I use = require admin_routes, Routes is undefined and AdminRoutes just contains options but no routes: http://screencast.com/t/6pHezoqU7
Both cases are not what I expect.
Very confusing all that. What am I doing wrong?
Why do you put generation of js files in initializer? If you need both routes, just add this in your js file with .erb prefix - assets pipeline will do all work. Example:
<%= JsRoutes.generate(namespace: "Routes", exclude: [/admin/]) %>
<%= JsRoutes.generate(namespace: "AdminRoutes", include: /admin/) %>
That works, thanks! But where would you use JsRoutes.generate! if not in an initializer?
@manuelmeurer for example, in rake task: if you need deploy routes, but impossible to load env for assets pipeline (like on heroku). Or you just need generate static routes once: again or rake task, or some Ruby script.
Ok, the README is not very clear on that, I will submit a PR.