EdvardM
1/11/2013 - 1:48 PM

rails url_for hack with prefix

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