Sha256: 010d0a451c256ec18f3981f6cee282c9c1cbc01cf82ba11bb50734211b2cf871
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
# Rails::Routes::Js::Utils Make rails route available via window.Routes.*_path() and Array window.AllRoutes ## Installation Add this line to your application's Gemfile: gem 'rails-routes-js-utils' And then execute: $ bundle Or install it yourself as: $ gem install rails-routes-js-utils Add this to application.js ``` //= require rails-routes-js-utils ``` ## Usage ```javascript Routes.blog_post_path(123) Routes.blog_post_path({id: 123}) Routes.blog_posts_path() for (var i=0; i<AllRoutes.length; i++){ var route = AllRoutes[i]; var subdomain = document.location.hostname.split('.')[0]; var pathname = document.location.pathname; if (route.path.test(pathname) && route.subdomain.test(subdomain)) { // Matched route console.log(route); var controller = route.reqs.controller; var action = route.reqs.action; var parts = route.reqs.parts; } ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rails-routes-js-utils-2.0.0 | README.md |
rails-routes-js-utils-1.2.1 | README.md |
rails-routes-js-utils-1.2.0 | README.md |
rails-routes-js-utils-1.1.4 | README.md |