Skip to content

Commit

Permalink
Merge pull request #99 from krautcomputing/readme_fix
Browse files Browse the repository at this point in the history
Clarify advanced setup instructions
  • Loading branch information
bogdan committed Feb 28, 2014
2 parents 6dc8fac + 921275b commit 7f52df6
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions Readme.md
Expand Up @@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit 7f52df6

Please sign in to comment.