url_for.rb 738 字节
Newer Older
1 2 3 4 5 6
module ActionController
  module UrlFor
    extend ActiveSupport::Concern

    include ActionDispatch::Routing::UrlFor

7
    def url_options
8 9 10 11
      super.reverse_merge(
        :host => request.host_with_port,
        :protocol => request.protocol,
        :_path_segments => request.symbolized_path_parameters
12
      ).merge(:script_name => request.script_name)
13 14 15 16
    end

    def _router
      raise "In order to use #url_for, you must include the helpers of a particular " \
17
            "router. For instance, `include Rails.application.routes.url_helpers"
18
    end
19 20 21 22 23 24 25 26

    module ClassMethods
      def action_methods
        @action_methods ||= begin
          super - _router.named_routes.helper_names
        end
      end
    end
27 28
  end
end