Skip to content

Instantly share code, notes, and snippets.

@khoan
Created November 24, 2011 02:18
Show Gist options
  • Save khoan/1390486 to your computer and use it in GitHub Desktop.
Save khoan/1390486 to your computer and use it in GitHub Desktop.
Rails 3.1 url helper in sprockets with relative_url_root
# So I was trying to use named route helpers in sprockets, and the app was hosted in a subdirectory.
# This is what I came up with. Please share your hackeries.
#
# using named routes in sprocket Rails 3.1
# you can use this in app/assets/javascripts/bam.js.erb
# or any other erb sprocket asset
Rails.application.routes.url_helpers.bam_path(
:script_name => ApplicationController.config.relative_url_root
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment