提交 9e5d64b3 编写于 作者: N Nicholas Seckar

Provide Named Route's hash methods as helper methods. Closes #1744.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2204 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 b646e0dd
*SVN*
* Provide Named Route's hash methods as helper methods. Closes #1744. [Nicholas Seckar, Steve Purcell]
* Added :multipart option to ActiveRecordHelper#form to make it possible to add file input fields #2034 [jstirk@oobleyboo.com]
* Moved auto-completion and in-place editing into the Macros module and their helper counterparts into JavaScriptMacrosHelper
......
......@@ -621,7 +621,9 @@ def known_hash_for_route(route)
def define_hash_access_method(route, name)
hash = known_hash_for_route(route)
define_method(hash_access_name(name)) { hash }
define_method(hash_access_name(name)) do |*args|
args.first ? hash.merge(args.first) : hash
end
end
def name_route(route, name)
......@@ -634,6 +636,7 @@ def name_route(route, name)
protected url_helper_name(name), hash_access_name(name)
Helpers << url_helper_name(name).to_sym
Helpers << hash_access_name(name).to_sym
Helpers.uniq!
end
......
......@@ -545,6 +545,7 @@ class RouteSetTests < Test::Unit::TestCase
def setup
@rs = ::ActionController::Routing::RouteSet.new
@rs.draw {|m| m.connect ':controller/:action/:id' }
::ActionController::Routing::NamedRoutes.clear
end
def test_default_setup
......@@ -854,6 +855,11 @@ def test_named_route_method
assert_equal ['/content/hi', []], rs.generate({:controller => 'content', :action => 'hi'})
end
def test_named_route_helper_array
test_named_route_method
assert_equal [:categories_url, :hash_for_categories_url], ::ActionController::Routing::NamedRoutes::Helpers
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册