Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6c5f43ba
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,发现更多精彩内容 >>
提交
6c5f43ba
编写于
5月 27, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e048
上级
cd037783
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
228 addition
and
218 deletion
+228
-218
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+4
-0
actionpack/lib/abstract_controller/callbacks.rb
actionpack/lib/abstract_controller/callbacks.rb
+24
-20
actionpack/test/abstract/callbacks_test.rb
actionpack/test/abstract/callbacks_test.rb
+5
-3
actionpack/test/controller/filters_test.rb
actionpack/test/controller/filters_test.rb
+190
-190
actionpack/test/controller/test_case_test.rb
actionpack/test/controller/test_case_test.rb
+1
-1
railties/lib/rails/info_controller.rb
railties/lib/rails/info_controller.rb
+1
-1
railties/lib/rails/mailers_controller.rb
railties/lib/rails/mailers_controller.rb
+3
-3
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
6c5f43ba
*
Deprecate all
*_filter callbacks in favor of *
_action callbacks.
*Rafael Mendonça França*
*
Fix URL generation with
`:trailing_slash`
such that it does not add
*
Fix URL generation with
`:trailing_slash`
such that it does not add
a trailing slash after
`.:format`
a trailing slash after
`.:format`
...
...
actionpack/lib/abstract_controller/callbacks.rb
浏览文件 @
6c5f43ba
require
'active_support/deprecation'
module
AbstractController
module
AbstractController
module
Callbacks
module
Callbacks
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
...
@@ -42,21 +44,23 @@ def _normalize_callback_option(options, from, to) # :nodoc:
...
@@ -42,21 +44,23 @@ def _normalize_callback_option(options, from, to) # :nodoc:
end
end
end
end
# Skip before, after, and around action callbacks matching any of the names
# Skip before, after, and around action callbacks matching any of the names.
# Aliased as skip_filter.
#
#
# ==== Parameters
# ==== Parameters
# * <tt>names</tt> - A list of valid names that could be used for
# * <tt>names</tt> - A list of valid names that could be used for
# callbacks. Note that skipping uses Ruby equality, so it's
# callbacks. Note that skipping uses Ruby equality, so it's
# impossible to skip a callback defined using an anonymous proc
# impossible to skip a callback defined using an anonymous proc
# using #skip_
filter
# using #skip_
action_callback
def
skip_action_callback
(
*
names
)
def
skip_action_callback
(
*
names
)
skip_before_action
(
*
names
)
skip_before_action
(
*
names
)
skip_after_action
(
*
names
)
skip_after_action
(
*
names
)
skip_around_action
(
*
names
)
skip_around_action
(
*
names
)
end
end
alias_method
:skip_filter
,
:skip_action_callback
def
skip_filter
(
*
names
)
ActiveSupport
::
Deprecation
.
warn
(
"
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use
#{
callback
}
_action instead."
)
skip_action_callback
(
*
names
)
end
# Take callback names and an optional callback proc, normalize them,
# Take callback names and an optional callback proc, normalize them,
# then call the block with each callback. This allows us to abstract
# then call the block with each callback. This allows us to abstract
...
@@ -85,7 +89,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -85,7 +89,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: before_action(names, block)
# :call-seq: before_action(names, block)
#
#
# Append a callback before actions. See _insert_callbacks for parameter details.
# Append a callback before actions. See _insert_callbacks for parameter details.
# Aliased as before_filter.
##
##
# :method: prepend_before_action
# :method: prepend_before_action
...
@@ -93,7 +96,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -93,7 +96,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_before_action(names, block)
# :call-seq: prepend_before_action(names, block)
#
#
# Prepend a callback before actions. See _insert_callbacks for parameter details.
# Prepend a callback before actions. See _insert_callbacks for parameter details.
# Aliased as prepend_before_filter.
##
##
# :method: skip_before_action
# :method: skip_before_action
...
@@ -101,7 +103,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -101,7 +103,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: skip_before_action(names)
# :call-seq: skip_before_action(names)
#
#
# Skip a callback before actions. See _insert_callbacks for parameter details.
# Skip a callback before actions. See _insert_callbacks for parameter details.
# Aliased as skip_before_filter.
##
##
# :method: append_before_action
# :method: append_before_action
...
@@ -109,7 +110,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -109,7 +110,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: append_before_action(names, block)
# :call-seq: append_before_action(names, block)
#
#
# Append a callback before actions. See _insert_callbacks for parameter details.
# Append a callback before actions. See _insert_callbacks for parameter details.
# Aliased as append_before_filter.
##
##
# :method: after_action
# :method: after_action
...
@@ -117,7 +117,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -117,7 +117,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: after_action(names, block)
# :call-seq: after_action(names, block)
#
#
# Append a callback after actions. See _insert_callbacks for parameter details.
# Append a callback after actions. See _insert_callbacks for parameter details.
# Aliased as after_filter.
##
##
# :method: prepend_after_action
# :method: prepend_after_action
...
@@ -125,7 +124,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -125,7 +124,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_after_action(names, block)
# :call-seq: prepend_after_action(names, block)
#
#
# Prepend a callback after actions. See _insert_callbacks for parameter details.
# Prepend a callback after actions. See _insert_callbacks for parameter details.
# Aliased as prepend_after_filter.
##
##
# :method: skip_after_action
# :method: skip_after_action
...
@@ -133,7 +131,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -133,7 +131,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: skip_after_action(names)
# :call-seq: skip_after_action(names)
#
#
# Skip a callback after actions. See _insert_callbacks for parameter details.
# Skip a callback after actions. See _insert_callbacks for parameter details.
# Aliased as skip_after_filter.
##
##
# :method: append_after_action
# :method: append_after_action
...
@@ -141,7 +138,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -141,7 +138,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: append_after_action(names, block)
# :call-seq: append_after_action(names, block)
#
#
# Append a callback after actions. See _insert_callbacks for parameter details.
# Append a callback after actions. See _insert_callbacks for parameter details.
# Aliased as append_after_filter.
##
##
# :method: around_action
# :method: around_action
...
@@ -149,7 +145,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -149,7 +145,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: around_action(names, block)
# :call-seq: around_action(names, block)
#
#
# Append a callback around actions. See _insert_callbacks for parameter details.
# Append a callback around actions. See _insert_callbacks for parameter details.
# Aliased as around_filter.
##
##
# :method: prepend_around_action
# :method: prepend_around_action
...
@@ -157,7 +152,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -157,7 +152,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_around_action(names, block)
# :call-seq: prepend_around_action(names, block)
#
#
# Prepend a callback around actions. See _insert_callbacks for parameter details.
# Prepend a callback around actions. See _insert_callbacks for parameter details.
# Aliased as prepend_around_filter.
##
##
# :method: skip_around_action
# :method: skip_around_action
...
@@ -165,7 +159,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -165,7 +159,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: skip_around_action(names)
# :call-seq: skip_around_action(names)
#
#
# Skip a callback around actions. See _insert_callbacks for parameter details.
# Skip a callback around actions. See _insert_callbacks for parameter details.
# Aliased as skip_around_filter.
##
##
# :method: append_around_action
# :method: append_around_action
...
@@ -173,7 +166,6 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -173,7 +166,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: append_around_action(names, block)
# :call-seq: append_around_action(names, block)
#
#
# Append a callback around actions. See _insert_callbacks for parameter details.
# Append a callback around actions. See _insert_callbacks for parameter details.
# Aliased as append_around_filter.
# set up before_action, prepend_before_action, skip_before_action, etc.
# set up before_action, prepend_before_action, skip_before_action, etc.
# for each of before, after, and around.
# for each of before, after, and around.
...
@@ -184,7 +176,10 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -184,7 +176,10 @@ def _insert_callbacks(callbacks, block = nil)
end
end
end
end
alias_method
:"
#{
callback
}
_filter"
,
:"
#{
callback
}
_action"
define_method
"
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use
#{
callback
}
_action instead."
)
send
(
"
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
define_method
"prepend_
#{
callback
}
_action"
do
|*
names
,
&
blk
|
define_method
"prepend_
#{
callback
}
_action"
do
|*
names
,
&
blk
|
_insert_callbacks
(
names
,
blk
)
do
|
name
,
options
|
_insert_callbacks
(
names
,
blk
)
do
|
name
,
options
|
...
@@ -192,7 +187,10 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -192,7 +187,10 @@ def _insert_callbacks(callbacks, block = nil)
end
end
end
end
alias_method
:"prepend_
#{
callback
}
_filter"
,
:"prepend_
#{
callback
}
_action"
define_method
"prepend_
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"prepend_
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use prepend_
#{
callback
}
_action instead."
)
send
(
"prepend_
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
# Skip a before, after or around callback. See _insert_callbacks
# Skip a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
# for details on the allowed parameters.
...
@@ -202,11 +200,17 @@ def _insert_callbacks(callbacks, block = nil)
...
@@ -202,11 +200,17 @@ def _insert_callbacks(callbacks, block = nil)
end
end
end
end
alias_method
:"skip_
#{
callback
}
_filter"
,
:"skip_
#{
callback
}
_action"
define_method
"skip_
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"skip_
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use skip_
#{
callback
}
_action instead."
)
send
(
"skip_
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
# *_action is the same as append_*_action
# *_action is the same as append_*_action
alias_method
:"append_
#{
callback
}
_action"
,
:"
#{
callback
}
_action"
# alias_method :append_before_action, :before_action
alias_method
:"append_
#{
callback
}
_action"
,
:"
#{
callback
}
_action"
# alias_method :append_before_action, :before_action
alias_method
:"append_
#{
callback
}
_filter"
,
:"
#{
callback
}
_action"
# alias_method :append_before_filter, :before_action
define_method
"append_
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"append_
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use append_
#{
callback
}
_action instead."
)
send
(
"append_
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
end
end
end
end
end
end
...
...
actionpack/test/abstract/callbacks_test.rb
浏览文件 @
6c5f43ba
...
@@ -267,9 +267,11 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
...
@@ -267,9 +267,11 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
end
end
class
AliasedCallbacks
<
ControllerWithCallbacks
class
AliasedCallbacks
<
ControllerWithCallbacks
before_filter
:first
ActiveSupport
::
Deprecation
.
silence
do
after_filter
:second
before_filter
:first
around_filter
:aroundz
after_filter
:second
around_filter
:aroundz
end
def
first
def
first
@text
=
"Hello world"
@text
=
"Hello world"
...
...
actionpack/test/controller/filters_test.rb
浏览文件 @
6c5f43ba
此差异已折叠。
点击以展开。
actionpack/test/controller/test_case_test.rb
浏览文件 @
6c5f43ba
...
@@ -164,7 +164,7 @@ def view_assigns
...
@@ -164,7 +164,7 @@ def view_assigns
end
end
class
DefaultUrlOptionsCachingController
<
ActionController
::
Base
class
DefaultUrlOptionsCachingController
<
ActionController
::
Base
before_
filter
{
@dynamic_opt
=
'opt'
}
before_
action
{
@dynamic_opt
=
'opt'
}
def
test_url_options_reset
def
test_url_options_reset
render
text:
url_for
(
params
)
render
text:
url_for
(
params
)
...
...
railties/lib/rails/info_controller.rb
浏览文件 @
6c5f43ba
...
@@ -5,7 +5,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
...
@@ -5,7 +5,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
prepend_view_path
ActionDispatch
::
DebugExceptions
::
RESCUES_TEMPLATE_PATH
prepend_view_path
ActionDispatch
::
DebugExceptions
::
RESCUES_TEMPLATE_PATH
layout
->
{
request
.
xhr?
?
false
:
'application'
}
layout
->
{
request
.
xhr?
?
false
:
'application'
}
before_
filter
:require_local!
before_
action
:require_local!
def
index
def
index
redirect_to
action: :routes
redirect_to
action: :routes
...
...
railties/lib/rails/mailers_controller.rb
浏览文件 @
6c5f43ba
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
class
Rails::MailersController
<
Rails
::
ApplicationController
# :nodoc:
class
Rails::MailersController
<
Rails
::
ApplicationController
# :nodoc:
prepend_view_path
ActionDispatch
::
DebugExceptions
::
RESCUES_TEMPLATE_PATH
prepend_view_path
ActionDispatch
::
DebugExceptions
::
RESCUES_TEMPLATE_PATH
before_
filter
:require_local!
before_
action
:require_local!
before_
filter
:find_preview
,
only: :preview
before_
action
:find_preview
,
only: :preview
def
index
def
index
@previews
=
ActionMailer
::
Preview
.
all
@previews
=
ActionMailer
::
Preview
.
all
...
@@ -70,4 +70,4 @@ def find_part(format)
...
@@ -70,4 +70,4 @@ def find_part(format)
@email
@email
end
end
end
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录