https://github.com/llopez/js_router
Map rails routes helpers to javascripts functions
https://github.com/llopez/js_router
Last synced: 10 months ago
JSON representation
Map rails routes helpers to javascripts functions
- Host: GitHub
- URL: https://github.com/llopez/js_router
- Owner: llopez
- Created: 2011-03-04T04:41:18.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2013-02-26T18:40:30.000Z (over 13 years ago)
- Last Synced: 2025-04-03T13:49:35.153Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 121 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Js Router
=========
[](https://travis-ci.org/llopez/js_router)
### Introduction:
This is a Rails Engine for Rails3.
Map your rails url helpers into javascript.
### Installation:
Add to your Gemfile.
gem 'js_router', :git => 'git://github.com/llopez/js_router.git'
Then:
$ bundle
### Dependencies:
This engine uses the yui-compressor gem for compact javascripts.
gem install yui-compressor
### Setup:
In your application layout.
javascript_include_tag '/javascripts/routes', 'application'
### Now you can do:
If your config/routes.rb file looks like this:
YourApp::Application.routes.draw do
resources :posts
end
You can do:
jsRouter.postsPath() => /posts
jsRouter.newPostPath() => /posts/new
jsRouter.postPath(1) => /posts/1
jsRouter.editPostPath(1) => /posts/1/edit
Or with extra params:
postPath(1, {name: 'john', type: 'person'}) => /posts/1?name=john&type=person
### Testing
rake test
### TODO
Generate urls with domain.
### Author
llopez (Luis Lopez).