Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0b4cfa2b
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,发现更多精彩内容 >>
提交
0b4cfa2b
编写于
9月 19, 2018
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't expose internal methods in the associations
上级
2b5b08b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
32 deletion
+32
-32
activerecord/lib/active_record/associations/association.rb
activerecord/lib/active_record/associations/association.rb
+18
-18
activerecord/lib/active_record/associations/has_many_through_association.rb
...ctive_record/associations/has_many_through_association.rb
+14
-14
未找到文件。
activerecord/lib/active_record/associations/association.rb
浏览文件 @
0b4cfa2b
...
...
@@ -79,18 +79,6 @@ def scope
target_scope
.
merge!
(
association_scope
)
end
# The scope for this association.
#
# Note that the association_scope is merged into the target_scope only when the
# scope method is called. This is because at that point the call may be surrounded
# by scope.scoping { ... } or with_scope { ... } etc, which affects the scope which
# actually gets built.
def
association_scope
if
klass
@association_scope
||=
AssociationScope
.
scope
(
self
)
end
end
def
reset_scope
@association_scope
=
nil
end
...
...
@@ -129,12 +117,6 @@ def klass
reflection
.
klass
end
# Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the
# through association's scope)
def
target_scope
AssociationRelation
.
create
(
klass
,
self
).
merge!
(
klass
.
all
)
end
def
extensions
extensions
=
klass
.
default_extensions
|
reflection
.
extensions
...
...
@@ -195,6 +177,24 @@ def create!(attributes = {}, &block)
end
private
# The scope for this association.
#
# Note that the association_scope is merged into the target_scope only when the
# scope method is called. This is because at that point the call may be surrounded
# by scope.scoping { ... } or unscoped { ... } etc, which affects the scope which
# actually gets built.
def
association_scope
if
klass
@association_scope
||=
AssociationScope
.
scope
(
self
)
end
end
# Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the
# through association's scope)
def
target_scope
AssociationRelation
.
create
(
klass
,
self
).
merge!
(
klass
.
all
)
end
def
scope_for_create
scope
.
scope_for_create
end
...
...
activerecord/lib/active_record/associations/has_many_through_association.rb
浏览文件 @
0b4cfa2b
...
...
@@ -21,20 +21,6 @@ def concat(*records)
super
end
def
concat_records
(
records
)
ensure_not_nested
records
=
super
(
records
,
true
)
if
owner
.
new_record?
&&
records
records
.
flatten
.
each
do
|
record
|
build_through_record
(
record
)
end
end
records
end
def
insert_record
(
record
,
validate
=
true
,
raise
=
false
)
ensure_not_nested
...
...
@@ -48,6 +34,20 @@ def insert_record(record, validate = true, raise = false)
end
private
def
concat_records
(
records
)
ensure_not_nested
records
=
super
(
records
,
true
)
if
owner
.
new_record?
&&
records
records
.
flatten
.
each
do
|
record
|
build_through_record
(
record
)
end
end
records
end
# The through record (built with build_record) is temporarily cached
# so that it may be reused if insert_record is subsequently called.
#
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录