Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
432c3661
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,发现更多精彩内容 >>
提交
432c3661
编写于
12月 21, 2011
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4121 from lest/remove-whiny-nils
remove AS whiny nil extension and deprecate config.whiny_nils
上级
667d7aa6
4f6af26a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
6 addition
and
46 deletion
+6
-46
activesupport/lib/active_support/railtie.rb
activesupport/lib/active_support/railtie.rb
+0
-6
activesupport/lib/active_support/whiny_nil.rb
activesupport/lib/active_support/whiny_nil.rb
+0
-22
activesupport/test/whiny_nil_test.rb
activesupport/test/whiny_nil_test.rb
+0
-11
railties/lib/rails/application/configuration.rb
railties/lib/rails/application/configuration.rb
+6
-1
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
...rails/app/templates/config/environments/development.rb.tt
+0
-3
railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
...rators/rails/app/templates/config/environments/test.rb.tt
+0
-3
未找到文件。
activesupport/lib/active_support/railtie.rb
浏览文件 @
432c3661
...
...
@@ -5,12 +5,6 @@ module ActiveSupport
class
Railtie
<
Rails
::
Railtie
config
.
active_support
=
ActiveSupport
::
OrderedOptions
.
new
# Loads support for "whiny nil" (noisy warnings when methods are invoked
# on +nil+ values) if Configuration#whiny_nils is true.
initializer
"active_support.initialize_whiny_nils"
do
|
app
|
require
'active_support/whiny_nil'
if
app
.
config
.
whiny_nils
end
initializer
"active_support.deprecation_behavior"
do
|
app
|
if
deprecation
=
app
.
config
.
active_support
.
deprecation
ActiveSupport
::
Deprecation
.
behavior
=
deprecation
...
...
activesupport/lib/active_support/whiny_nil.rb
已删除
100644 → 0
浏览文件 @
667d7aa6
# Extensions to +nil+ which allow for more helpful error messages for people who
# are new to Rails.
#
# NilClass#id exists in Ruby 1.8 (though it is deprecated). Since +id+ is a fundamental
# method of Active Record models NilClass#id is redefined as well to raise a RuntimeError
# and warn the user. She probably wanted a model database identifier and the 4
# returned by the original method could result in obscure bugs.
#
# The flag <tt>config.whiny_nils</tt> determines whether this feature is enabled.
# By default it is on in development and test modes, and it is off in production
# mode.
class
NilClass
def
self
.
add_whiner
(
klass
)
ActiveSupport
::
Deprecation
.
warn
"NilClass.add_whiner is deprecated and this functionality is "
\
"removed from Rails versions as it affects Ruby 1.9 performance."
,
caller
end
# Raises a RuntimeError when you attempt to call +id+ on +nil+.
def
id
raise
RuntimeError
,
"Called id for nil, which would mistakenly be
#{
object_id
}
-- if you really wanted the id of nil, use object_id"
,
caller
end
end
activesupport/test/whiny_nil_test.rb
已删除
100644 → 0
浏览文件 @
667d7aa6
require
'abstract_unit'
require
'active_support/whiny_nil'
class
WhinyNilTest
<
Test
::
Unit
::
TestCase
def
test_id
nil
.
id
rescue
RuntimeError
=>
nme
assert_no_match
(
/nil:NilClass/
,
nme
.
message
)
assert_match
(
Regexp
.
new
(
nil
.
object_id
.
to_s
),
nme
.
message
)
end
end
railties/lib/rails/application/configuration.rb
浏览文件 @
432c3661
...
...
@@ -12,7 +12,7 @@ class Configuration < ::Rails::Engine::Configuration
:force_ssl
,
:helpers_paths
,
:logger
,
:log_tags
,
:preload_frameworks
,
:railties_order
,
:relative_url_root
,
:reload_plugins
,
:secret_token
,
:serve_static_assets
,
:ssl_options
,
:static_cache_control
,
:session_options
,
:time_zone
,
:reload_classes_only_on_change
,
:whiny_nils
:time_zone
,
:reload_classes_only_on_change
attr_writer
:log_level
attr_reader
:encoding
...
...
@@ -145,6 +145,11 @@ def session_store(*args)
@session_options
=
args
.
shift
||
{}
end
end
def
whiny_nils
=
(
*
)
ActiveSupport
::
Deprecation
.
warn
"config.whiny_nils option "
\
"is deprecated and no longer works"
,
caller
end
end
end
end
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
浏览文件 @
432c3661
...
...
@@ -6,9 +6,6 @@
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
浏览文件 @
432c3661
...
...
@@ -11,9 +11,6 @@
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录