Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
aa86420b
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,发现更多精彩内容 >>
提交
aa86420b
编写于
1月 24, 2011
作者:
J
Jon Leighton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename AssociationProxy#loaded to loaded! as it mutates the association
上级
de05e2fb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
10 addition
and
10 deletion
+10
-10
activerecord/lib/active_record/association_preload.rb
activerecord/lib/active_record/association_preload.rb
+3
-3
activerecord/lib/active_record/associations/association_collection.rb
.../lib/active_record/associations/association_collection.rb
+1
-1
activerecord/lib/active_record/associations/association_proxy.rb
...ecord/lib/active_record/associations/association_proxy.rb
+3
-3
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
...tive_record/associations/class_methods/join_dependency.rb
+1
-1
activerecord/lib/active_record/associations/has_many_association.rb
...rd/lib/active_record/associations/has_many_association.rb
+1
-1
activerecord/lib/active_record/autosave_association.rb
activerecord/lib/active_record/autosave_association.rb
+1
-1
未找到文件。
activerecord/lib/active_record/association_preload.rb
浏览文件 @
aa86420b
...
...
@@ -125,7 +125,7 @@ def preload_one_association(records, association, preload_options={})
def
add_preloaded_records_to_collection
(
parent_records
,
reflection_name
,
associated_record
)
parent_records
.
each
do
|
parent_record
|
association_proxy
=
parent_record
.
send
(
reflection_name
)
association_proxy
.
loaded
association_proxy
.
loaded
!
association_proxy
.
target
.
concat
(
Array
.
wrap
(
associated_record
))
association_proxy
.
send
(
:set_inverse_instance
,
associated_record
)
end
...
...
@@ -187,7 +187,7 @@ def preload_has_and_belongs_to_many_association(records, reflection, preload_opt
id_to_record_map
=
construct_id_map
(
records
)
records
.
each
{
|
record
|
record
.
send
(
reflection
.
name
).
loaded
}
records
.
each
{
|
record
|
record
.
send
(
reflection
.
name
).
loaded!
}
options
=
reflection
.
options
right
=
Arel
::
Table
.
new
(
options
[
:join_table
]).
alias
(
't0'
)
...
...
@@ -268,7 +268,7 @@ def preload_has_many_association(records, reflection, preload_options={})
foreign_key
=
reflection
.
through_reflection_foreign_key
id_to_record_map
=
construct_id_map
(
records
,
foreign_key
||
reflection
.
options
[
:primary_key
])
records
.
each
{
|
record
|
record
.
send
(
reflection
.
name
).
loaded
}
records
.
each
{
|
record
|
record
.
send
(
reflection
.
name
).
loaded!
}
if
options
[
:through
]
through_records
=
preload_through_records
(
records
,
reflection
,
options
[
:through
])
...
...
activerecord/lib/active_record/associations/association_collection.rb
浏览文件 @
aa86420b
...
...
@@ -371,7 +371,7 @@ def load_target
@target
=
merge_target_lists
(
targets
,
@target
)
end
loaded
loaded
!
target
end
...
...
activerecord/lib/active_record/associations/association_proxy.rb
浏览文件 @
aa86420b
...
...
@@ -128,7 +128,7 @@ def loaded?
end
# Asserts the \target has been loaded setting the \loaded flag to +true+.
def
loaded
def
loaded
!
@loaded
=
true
@stale_state
=
stale_state
end
...
...
@@ -152,7 +152,7 @@ def stale_target?
# Sets the target of this proxy to <tt>\target</tt>, and the \loaded flag to +true+.
def
target
=
(
target
)
@target
=
target
loaded
loaded
!
end
# Forwards the call to the target. Loads the \target if needed.
...
...
@@ -227,7 +227,7 @@ def target_scope
# not reraised. The proxy is \reset and +nil+ is the return value.
def
load_target
@target
=
find_target
if
find_target?
loaded
loaded
!
target
rescue
ActiveRecord
::
RecordNotFound
reset
...
...
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
浏览文件 @
aa86420b
...
...
@@ -210,7 +210,7 @@ def construct_association(record, join_part, row)
case
macro
when
:has_many
,
:has_and_belongs_to_many
collection
=
record
.
send
(
join_part
.
reflection
.
name
)
collection
.
loaded
collection
.
loaded
!
collection
.
target
.
push
(
association
)
collection
.
send
(
:set_inverse_instance
,
association
)
when
:belongs_to
...
...
activerecord/lib/active_record/associations/has_many_association.rb
浏览文件 @
aa86420b
...
...
@@ -40,7 +40,7 @@ def count_records
# If there's nothing in the database and @target has no new records
# we are certain the current target is an empty array. This is a
# documented side-effect of the method that may avoid an extra SELECT.
@target
||=
[]
and
loaded
if
count
==
0
@target
||=
[]
and
loaded
!
if
count
==
0
[
@reflection
.
options
[
:limit
],
count
].
compact
.
min
end
...
...
activerecord/lib/active_record/autosave_association.rb
浏览文件 @
aa86420b
...
...
@@ -368,7 +368,7 @@ def save_belongs_to_association(reflection)
if
association
.
updated?
association_id
=
association
.
send
(
reflection
.
options
[
:primary_key
]
||
:id
)
self
[
reflection
.
foreign_key
]
=
association_id
association
.
loaded
association
.
loaded
!
end
saved
if
autosave
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录