Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6722

Show
Ignore:
Timestamp:
05/12/07 04:18:46 (2 years ago)
Author:
ulysses
Message:

Add ActionController::Routing::Helpers, a module to contain common URL helpers such as polymorphic_url.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6699 r6722  
    11*SVN* 
     2 
     3* Add ActionController::Routing::Helpers, a module to contain common URL helpers such as polymorphic_url. [Nicholas Seckar] 
    24 
    35* Included the HttpAuthentication plugin as part of core (ActionController::HttpAuthentication::Basic) [DHH] 
  • trunk/actionpack/lib/action_controller/integration.rb

    r6203 r6722  
    7676          # install the named routes in this session instance. 
    7777          klass = class<<self; self; end 
    78           Routing::Routes.named_routes.install(klass) 
     78          Routing::Routes.install_helpers(klass) 
    7979 
    8080          # the helpers are made protected by default--we make them public for 
  • trunk/actionpack/lib/action_controller/routing.rb

    r6673 r6722  
    253253    mattr_accessor :controller_paths 
    254254    self.controller_paths = [] 
    255  
     255     
     256    # A helper module to hold URL related helpers. 
     257    module Helpers 
     258    end 
     259     
    256260    class << self 
    257261      def with_controllers(names) 
     
    11351139        clear! 
    11361140        yield Mapper.new(self) 
    1137         named_routes.install 
    1138       end 
    1139    
     1141        install_helpers 
     1142      end 
     1143       
    11401144      def clear! 
    11411145        routes.clear 
     
    11441148        @routes_by_controller = nil 
    11451149      end 
     1150       
     1151      def install_helpers(destinations = [ActionController::Base, ActionView::Base]) 
     1152        Array(destinations).each { |d| d.send :include, Helpers } 
     1153        named_routes.install(destinations) 
     1154      end 
    11461155 
    11471156      def empty? 
     
    11531162        clear! 
    11541163        load_routes! 
    1155         named_routes.install 
     1164        install_helpers 
    11561165      end 
    11571166 
    11581167      alias reload load! 
    1159  
     1168       
    11601169      def load_routes! 
    11611170        if defined?(RAILS_ROOT) && defined?(::ActionController::Routing::Routes) && self == ::ActionController::Routing::Routes 
  • trunk/actionpack/lib/action_controller/url_rewriter.rb

    r6648 r6722  
    2222     
    2323    def self.included(base) #:nodoc: 
    24       ActionController::Routing::Routes.named_routes.install base 
     24      ActionController::Routing::Routes.install_helpers base 
    2525      base.mattr_accessor :default_url_options 
    2626      base.default_url_options ||= default_url_options 
  • trunk/actionpack/test/controller/action_pack_assertions_test.rb

    r6400 r6722  
    210210        map.connect   ':controller/:action/:id' 
    211211      end 
    212       set.named_routes.install 
     212      set.install_helpers 
    213213 
    214214      process :redirect_to_named_route 
  • trunk/actionpack/test/controller/routing_test.rb

    r6673 r6722  
    208208    x = Class.new 
    209209    x.send(:define_method, :url_for) {|x| x} 
    210     rs.named_routes.install(x) 
     210    rs.install_helpers(x) 
    211211    x 
    212212  end 
     
    14181418 
    14191419    klass = Class.new(MockController) 
    1420     set.named_routes.install(klass) 
     1420    set.install_helpers(klass) 
    14211421    klass.new(set) 
    14221422  end 
     
    18861886  end 
    18871887   
     1888  def test_routing_helper_module 
     1889    assert_kind_of Module, ActionController::Routing::Helpers 
     1890     
     1891    h = ActionController::Routing::Helpers 
     1892    c = Class.new 
     1893    assert ! c.ancestors.include?(h) 
     1894    ActionController::Routing::Routes.install_helpers c 
     1895    assert c.ancestors.include?(h) 
     1896  end 
     1897   
    18881898end