Fixed that named routes didn't use the default values for action and possible...

Fixed that named routes didn't use the default values for action and possible other parameters #1534 [Nicholas Seckar]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1758 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 afbf54bc
*SVN*
* Fixed that named routes didn't use the default values for action and possible other parameters #1534 [Nicholas Seckar]
* Fixed JavascriptHelper#visual_effect to use camelize such that :blind_up will work #1639 [pelletierm@eastmedia.net]
* Fixed that a SessionRestoreError was thrown if a model object was placed in the session that wasn't available to all controllers. This means that it's no longer necessary to use the 'model :post' work-around in ApplicationController to have a Post model in your session.
......
......@@ -256,13 +256,14 @@ def to_s() join '/' end
class Route #:nodoc:
attr_accessor :components, :known
attr_reader :path, :options, :keys
attr_reader :path, :options, :keys, :defaults
def initialize(path, options = {})
@path, @options = path, options
initialize_components path
defaults, conditions = initialize_hashes options.dup
@defaults = defaults.dup
configure_components(defaults, conditions)
initialize_keys
end
......@@ -576,7 +577,7 @@ def url_helper_name(name)
end
def name_route(route, name)
hash = route.known.symbolize_keys
hash = route.defaults.merge(route.known).symbolize_keys
hash[:controller] = "/#{hash[:controller]}"
define_method(hash_access_name(name)) { hash }
......
......@@ -663,6 +663,16 @@ def test_named_route_with_option
x.new.send(:page_url, :title => 'new stuff'))
end
def test_named_route_with_default
rs.page 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage'
x = setup_for_named_route
assert_equal({:controller => '/content', :action => 'show_page', :title => 'AboutPage'},
x.new.send(:page_url))
assert_equal({:controller => '/content', :action => 'show_page', :title => 'AboutRails'},
x.new.send(:page_url, :title => "AboutRails"))
end
def setup_for_named_route
x = Class.new
x.send(:define_method, :url_for) {|x| x}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册