Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d45a0e71
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d45a0e71
编写于
6月 03, 2017
作者:
K
Kasper Timm Hansen
提交者:
GitHub
6月 03, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29344 from y-yagi/fix_doc_format
Fix formatting of `direct` and `resolve` doc [ci skip]
上级
ab4f811d
7f0bbe79
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
14 deletion
+14
-14
actionpack/lib/action_dispatch/routing/mapper.rb
actionpack/lib/action_dispatch/routing/mapper.rb
+14
-14
未找到文件。
actionpack/lib/action_dispatch/routing/mapper.rb
浏览文件 @
d45a0e71
...
...
@@ -2038,8 +2038,8 @@ module CustomUrls
# { controller: "pages", action: "index", subdomain: "www" }
# end
#
# The return value from the block passed to
`direct`
must be a valid set of
# arguments for
`url_for`
which will actually build the URL string. This can
# The return value from the block passed to
+direct+
must be a valid set of
# arguments for
+url_for+
which will actually build the URL string. This can
# be one of the following:
#
# * A string, which is treated as a generated URL
...
...
@@ -2058,17 +2058,17 @@ module CustomUrls
# [ :products, options.merge(params.permit(:page, :size).to_h.symbolize_keys) ]
# end
#
# In this instance the
`params`
object comes from the context in which the the
# In this instance the
+params+
object comes from the context in which the the
# block is executed, e.g. generating a URL inside a controller action or a view.
# If the block is executed where there isn't a params object such as this:
#
# Rails.application.routes.url_helpers.browse_path
#
# then it will raise a
`NameError`
. Because of this you need to be aware of the
# then it will raise a
+NameError+
. Because of this you need to be aware of the
# context in which you will use your custom URL helper when defining it.
#
# NOTE: The
`direct`
method can't be used inside of a scope block such as
#
`namespace` or `scope`
and will raise an error if it detects that it is.
# NOTE: The
+direct+
method can't be used inside of a scope block such as
#
+namespace+ or +scope+
and will raise an error if it detects that it is.
def
direct
(
name
,
options
=
{},
&
block
)
unless
@scope
.
root?
raise
RuntimeError
,
"The direct method can't be used inside a routes scope block"
...
...
@@ -2078,8 +2078,8 @@ def direct(name, options = {}, &block)
end
# Define custom polymorphic mappings of models to URLs. This alters the
# behavior of
`polymorphic_url`
and consequently the behavior of
#
`link_to` and `form_for`
when passed a model instance, e.g:
# behavior of
+polymorphic_url+
and consequently the behavior of
#
+link_to+ and +form_for+
when passed a model instance, e.g:
#
# resource :basket
#
...
...
@@ -2087,8 +2087,8 @@ def direct(name, options = {}, &block)
# [:basket]
# end
#
# This will now generate "/basket" when a
`Basket`
instance is passed to
#
`link_to` or `form_for`
instead of the standard "/baskets/:id".
# This will now generate "/basket" when a
+Basket+
instance is passed to
#
+link_to+ or +form_for+
instead of the standard "/baskets/:id".
#
# NOTE: This custom behavior only applies to simple polymorphic URLs where
# a single model instance is passed and not more complicated forms, e.g:
...
...
@@ -2105,7 +2105,7 @@ def direct(name, options = {}, &block)
# link_to "Profile", @current_user
# link_to "Profile", [:admin, @current_user]
#
# The first
`link_to`
will generate "/profile" but the second will generate
# The first
+link_to+
will generate "/profile" but the second will generate
# the standard polymorphic URL of "/admin/users/1".
#
# You can pass options to a polymorphic mapping - the arity for the block
...
...
@@ -2116,11 +2116,11 @@ def direct(name, options = {}, &block)
# end
#
# This generates the URL "/basket#items" because when the last item in an
# array passed to
`polymorphic_url`
is a hash then it's treated as options
# array passed to
+polymorphic_url+
is a hash then it's treated as options
# to the URL helper that gets called.
#
# NOTE: The
`resolve`
method can't be used inside of a scope block such as
#
`namespace` or `scope`
and will raise an error if it detects that it is.
# NOTE: The
+resolve+
method can't be used inside of a scope block such as
#
+namespace+ or +scope+
and will raise an error if it detects that it is.
def
resolve
(
*
args
,
&
block
)
unless
@scope
.
root?
raise
RuntimeError
,
"The resolve method can't be used inside a routes scope block"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录