Skip to content

Instantly share code, notes, and snippets.

@edvardm
Created January 11, 2013 13:48
Show Gist options
  • Save edvardm/4510791 to your computer and use it in GitHub Desktop.
Save edvardm/4510791 to your computer and use it in GitHub Desktop.
rails url_for hack with prefix
# initializers/fix_relative_root_cells.rb
fail unless ActionDispatch::Routing::RouteSet
module ActionDispatch
module Routing
class RouteSet
alias url_for__ptsroot__ url_for
def url_for(options = {})
options[:script_name] = ENV['RAILS_RELATIVE_URL_ROOT'] if options.kind_of?(Hash)
options = Base.relative_url_root.to_s + options if options.kind_of?(String) and options.starts_with?('/')
url_for__ptsroot__(options)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment