Project

cone

0.01
No commit activity in last 3 years
No release in over 3 years
Rails client side URL helpers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 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:

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.