diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-03-17 16:04:41 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-03-17 16:05:29 -0500 |
commit | 13a783672aad338b9c7ade5319ec7967768905d7 (patch) | |
tree | 178fbfebf284ef25cbeeb1b5015e7a405ea91a88 /actionpack/lib | |
parent | b652aa81216f718f27ba257238d4c27dd54863b2 (diff) | |
download | rails-13a783672aad338b9c7ade5319ec7967768905d7.tar.gz rails-13a783672aad338b9c7ade5319ec7967768905d7.tar.bz2 rails-13a783672aad338b9c7ade5319ec7967768905d7.zip |
Install url helpers on module instance so they can be accessed
globally
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 5537bbbbe8..8936d7659a 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -65,7 +65,7 @@ module ActionDispatch # named routes. class NamedRouteCollection #:nodoc: include Enumerable - attr_reader :routes, :helpers + attr_reader :routes, :helpers, :module def initialize clear! @@ -241,21 +241,29 @@ module ActionDispatch def url_helpers @url_helpers ||= begin - router = self + routes = self - Module.new do + helpers = Module.new do extend ActiveSupport::Concern include UrlFor + @routes = routes + class << self + delegate :url_for, :to => '@routes' + end + extend routes.named_routes.module + # ROUTES TODO: install_helpers isn't great... can we make a module with the stuff that # we can include? # Yes plz - JP included do - router.install_helpers(self) + routes.install_helpers(self) end - define_method(:_router) { router } + define_method(:_router) { routes } end + + helpers end end |