Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lihanli/cone
client side rails url helpers
https://github.com/lihanli/cone
Last synced: 3 months ago
JSON representation
client side rails url helpers
- Host: GitHub
- URL: https://github.com/lihanli/cone
- Owner: lihanli
- License: mit
- Created: 2012-12-11T00:48:29.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-10-28T20:35:11.000Z (about 7 years ago)
- Last Synced: 2024-02-12T16:53:35.024Z (9 months ago)
- Language: Ruby
- Size: 53.7 KB
- Stars: 20
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# cone
Automatically generated Javascript URL helpers based on your Rails routes.
## Usage
```
user GET /users/:id(.:format) users#show
```
Let's say you have this Rails route. Here's how you would access it in Javascript with cone:```javascript
cone.userPath({ id: 12 });
"/users/12"cone.userPath({ id: 12, format: 'json' });
"/users/12.json"cone.userPath({ id: 12, format: 'json', foo: 'bar baz' });
"/users/12.json?foo=bar%20baz"cone.userPath({ id: 12, foo: 'bar baz', anchor: 'foo' });
"/users/12?foo=bar%20baz#foo"
```Reload the server whenever your routes change to have the Javascript regenerated.
## Installation
1. Add gem 'cone' to your Gemfile.
2. Run bundle install.
3. Add //= require cone to your Javascript manifest file (usually found at app/assets/javascripts/application.js).
4. Restart your server.