Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Clarify advanced setup instructions #99

Merged
merged 2 commits into from

2 participants

@manuelmeurer

I updated the readme instructions for the "very advanced setup" based on the discussion in #98

@bogdan
Collaborator

Looks pretty good.

But did you delete an examples with routes in a string routes = JsRoutes.generate ?

@manuelmeurer

Well I thought that is obvious from the way the routes are written in app/assets/javascripts/admin/routes.js.erb and app/assets/javascripts/application/routes.js.erb, but I can add it again if you think it makes more sense.

@bogdan
Collaborator

Hm, you are right, but lets be obvious for people that are looking exactly for this variant.

@bogdan bogdan merged commit 7f52df6 into railsware:master
@manuelmeurer manuelmeurer deleted the krautcomputing:readme_fix branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2014
  1. @manuelmeurer
Commits on Feb 28, 2014
  1. @manuelmeurer
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 9 deletions.
  1. +25 −9 Readme.md
View
34 Readme.md
@@ -67,9 +67,32 @@ Available options:
### Very Advanced Setup
-In case you need multiple route files for different parts of your application, you can not use asset pipeline.
+In case you need multiple route files for different parts of your application, you have to create the files manually.
+If your application has an `admin` and an `application` namespace for example:
-You need to generate routes files on the application side like this:
+```
+# app/assets/javascripts/admin/routes.js.erb
+<%= JsRoutes.generate(namespace: "AdminRoutes", include: /admin/) %>
+
+# app/assets/javascripts/admin.js.coffee
+#= require admin/routes
+```
+
+```
+# app/assets/javascripts/application/routes.js.erb
+<%= JsRoutes.generate(namespace: "AppRoutes", exclude: /admin/) %>
+
+# app/assets/javascripts/application.js.coffee
+#= require application/routes
+```
+
+In order to generate the routes to a string:
+
+```ruby
+routes_js = JsRoutes.generate(options)
+```
+
+If you want to generate the routes files outside of the asset pipeline, you can use `JsRoutes.generate!`:
``` ruby
path = "app/assets/javascripts"
@@ -78,13 +101,6 @@ JsRoutes.generate!("#{path}/adm_routes.js", :namespace => "AdmRoutes", :include
JsRoutes.generate!("#{path}/api_routes.js", :namespace => "ApiRoutes", :include => /^api_/, :default_url_options => {:format => "json"})
```
-In order to generate javascript to string and manipulate them yourself use:
-Like:
-
-``` ruby
-routes_js = JsRoutes.generate(options)
-```
-
## Usage
Configuration above will create a nice javascript file with `Routes` object that has all the rails routes available:
Something went wrong with that request. Please try again.