Socket
Book a DemoInstallSign in
Socket

asset_pipeline_routes

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset_pipeline_routes

0.3.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

asset_pipeline_routes

Build Status Gem Version

asset_pipeline_routes defines a r shorthand function which you can use inside your javascript assets.

What it does

Assuming you got a routes.rb with:

resources :users # => yields multiple routes, e.g. /users/:id(.:format)

Inside your javascript assets you can now write:

r(users_path)        // => yields '/users'
r(user_path)         // => yields '/users/{{id}}'
r(user_path, userId) // => yields '/users/'+userId

It works with coffeescript as well:

promise = $.rails.ajax({
  url: r(user_path, userId)
})

If you are compiling client side templates with the rails asset pipeline this works inside templates as well, e.g.

%form{ action: r(user_path) }

will generate

<form action='/users/{{id}}'></form>

Upgrading Notes

v0.2 introduced code breaking changes! THIS WILL NO LONGER WORK

// inside application.js.erb
var url = '<%= r.user_path 42 %>';

Instead, you can now drop the .erb extension and use r inline:

var url = r(user_path, 42);

Tests

You can run the test suite locally using the following commands:

$ gem install bundler
$ cd /path/to/local/asset_pipeline_routes
$ bundle install
$ bundle exec rake spec

Whatever you do, make sure the tests stay green ;)

License

Copyright © 2011-2013 Raphael Randschau nicolai86@me.com

asset_pipeline_routes is distributed under an MIT-style license. See LICENSE for details.

FAQs

Package last updated on 30 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.