Created
January 11, 2013 13:48
-
-
Save edvardm/4510791 to your computer and use it in GitHub Desktop.
rails url_for hack with prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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