Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
247886e1
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,发现更多精彩内容 >>
提交
247886e1
编写于
7月 15, 2010
作者:
Ł
Łukasz Strzałkowski
提交者:
Aaron Patterson
7月 19, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed warnings when a variable is shadowed
上级
b22c11fa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
12 addition
and
12 deletion
+12
-12
activerecord/lib/active_record/association_preload.rb
activerecord/lib/active_record/association_preload.rb
+2
-2
activerecord/lib/active_record/associations/association_collection.rb
.../lib/active_record/associations/association_collection.rb
+3
-3
activerecord/test/cases/associations/inverse_associations_test.rb
...cord/test/cases/associations/inverse_associations_test.rb
+2
-2
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+2
-2
activerecord/test/cases/fixtures_test.rb
activerecord/test/cases/fixtures_test.rb
+3
-3
未找到文件。
activerecord/lib/active_record/association_preload.rb
浏览文件 @
247886e1
...
...
@@ -112,13 +112,13 @@ def preload_one_association(records, association, preload_options={})
# Not all records have the same class, so group then preload
# group on the reflection itself so that if various subclass share the same association then we do not split them
# unnecessarily
records
.
group_by
{
|
record
|
class_to_reflection
[
record
.
class
]
||=
record
.
class
.
reflections
[
association
]}.
each
do
|
reflection
,
records
|
records
.
group_by
{
|
record
|
class_to_reflection
[
record
.
class
]
||=
record
.
class
.
reflections
[
association
]}.
each
do
|
reflection
,
_
records
|
raise
ConfigurationError
,
"Association named '
#{
association
}
' was not found; perhaps you misspelled it?"
unless
reflection
# 'reflection.macro' can return 'belongs_to', 'has_many', etc. Thus,
# the following could call 'preload_belongs_to_association',
# 'preload_has_many_association', etc.
send
(
"preload_
#{
reflection
.
macro
}
_association"
,
records
,
reflection
,
preload_options
)
send
(
"preload_
#{
reflection
.
macro
}
_association"
,
_
records
,
reflection
,
preload_options
)
end
end
...
...
activerecord/lib/active_record/associations/association_collection.rb
浏览文件 @
247886e1
...
...
@@ -218,9 +218,9 @@ def count(column_name = nil, options = {})
# are actually removed from the database, that depends precisely on
# +delete_records+. They are in any case removed from the collection.
def
delete
(
*
records
)
remove_records
(
records
)
do
|
records
,
old_records
|
remove_records
(
records
)
do
|
_
records
,
old_records
|
delete_records
(
old_records
)
if
old_records
.
any?
records
.
each
{
|
record
|
@target
.
delete
(
record
)
}
_
records
.
each
{
|
record
|
@target
.
delete
(
record
)
}
end
end
...
...
@@ -231,7 +231,7 @@ def delete(*records)
# ignoring the +:dependent+ option.
def
destroy
(
*
records
)
records
=
find
(
records
)
if
records
.
any?
{
|
record
|
record
.
kind_of?
(
Fixnum
)
||
record
.
kind_of?
(
String
)}
remove_records
(
records
)
do
|
records
,
old_records
|
remove_records
(
records
)
do
|
_
records
,
old_records
|
old_records
.
each
{
|
record
|
record
.
destroy
}
end
...
...
activerecord/test/cases/associations/inverse_associations_test.rb
浏览文件 @
247886e1
...
...
@@ -412,7 +412,7 @@ def test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many
i
=
interests
(
:trainspotting
)
m
=
i
.
man
assert_not_nil
m
.
interests
iz
=
m
.
interests
.
detect
{
|
iz
|
iz
.
id
==
i
.
id
}
iz
=
m
.
interests
.
detect
{
|
_iz
|
_
iz
.
id
==
i
.
id
}
assert_not_nil
iz
assert_equal
i
.
topic
,
iz
.
topic
,
"Interest topics should be the same before changes to child"
i
.
topic
=
'Eating cheese with a spoon'
...
...
@@ -516,7 +516,7 @@ def test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many
i
=
interests
(
:llama_wrangling
)
m
=
i
.
polymorphic_man
assert_not_nil
m
.
polymorphic_interests
iz
=
m
.
polymorphic_interests
.
detect
{
|
iz
|
iz
.
id
==
i
.
id
}
iz
=
m
.
polymorphic_interests
.
detect
{
|
_iz
|
_
iz
.
id
==
i
.
id
}
assert_not_nil
iz
assert_equal
i
.
topic
,
iz
.
topic
,
"Interest topics should be the same before changes to child"
i
.
topic
=
'Eating cheese with a spoon'
...
...
activerecord/test/cases/base_test.rb
浏览文件 @
247886e1
...
...
@@ -1816,8 +1816,8 @@ def test_to_xml_including_methods
def
test_to_xml_with_block
value
=
"Rockin' the block"
xml
=
Company
.
new
.
to_xml
(
:skip_instruct
=>
true
)
do
|
xml
|
xml
.
tag!
"arbitrary-element"
,
value
xml
=
Company
.
new
.
to_xml
(
:skip_instruct
=>
true
)
do
|
_
xml
|
_
xml
.
tag!
"arbitrary-element"
,
value
end
assert_equal
"<company>"
,
xml
.
first
(
9
)
assert
xml
.
include?
(
%(<arbitrary-element>#{value}</arbitrary-element>)
)
...
...
activerecord/test/cases/fixtures_test.rb
浏览文件 @
247886e1
...
...
@@ -36,7 +36,7 @@ def test_clean_fixtures
fixtures
=
nil
assert_nothing_raised
{
fixtures
=
create_fixtures
(
name
)
}
assert_kind_of
(
Fixtures
,
fixtures
)
fixtures
.
each
{
|
name
,
fixture
|
fixtures
.
each
{
|
_
name
,
fixture
|
fixture
.
each
{
|
key
,
value
|
assert_match
(
MATCH_ATTRIBUTE_NAME
,
key
)
}
...
...
@@ -229,9 +229,9 @@ def test_resets_to_min_pk_with_default_pk_and_sequence
def
test_create_fixtures_resets_sequences_when_not_cached
@instances
.
each
do
|
instance
|
max_id
=
create_fixtures
(
instance
.
class
.
table_name
).
inject
(
0
)
do
|
max_id
,
(
name
,
fixture
)
|
max_id
=
create_fixtures
(
instance
.
class
.
table_name
).
inject
(
0
)
do
|
_
max_id
,
(
name
,
fixture
)
|
fixture_id
=
fixture
[
'id'
].
to_i
fixture_id
>
max_id
?
fixture_id
:
max_id
fixture_id
>
_max_id
?
fixture_id
:
_
max_id
end
# Clone the last fixture to check that it gets the next greatest id.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录