Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f38b5444
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,发现更多精彩内容 >>
提交
f38b5444
编写于
7月 23, 2013
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a specific factory method rather than using new
上级
b0175623
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
11 addition
and
13 deletion
+11
-13
activerecord/lib/active_record/associations/association.rb
activerecord/lib/active_record/associations/association.rb
+1
-1
activerecord/lib/active_record/associations/collection_association.rb
.../lib/active_record/associations/collection_association.rb
+1
-1
activerecord/lib/active_record/associations/join_dependency/join_association.rb
...e_record/associations/join_dependency/join_association.rb
+2
-2
activerecord/lib/active_record/associations/preloader.rb
activerecord/lib/active_record/associations/preloader.rb
+1
-1
activerecord/lib/active_record/core.rb
activerecord/lib/active_record/core.rb
+1
-1
activerecord/lib/active_record/model_schema.rb
activerecord/lib/active_record/model_schema.rb
+1
-1
activerecord/lib/active_record/relation/delegation.rb
activerecord/lib/active_record/relation/delegation.rb
+2
-4
activerecord/lib/active_record/relation/merger.rb
activerecord/lib/active_record/relation/merger.rb
+1
-1
activerecord/lib/active_record/relation/spawn_methods.rb
activerecord/lib/active_record/relation/spawn_methods.rb
+1
-1
未找到文件。
activerecord/lib/active_record/associations/association.rb
浏览文件 @
f38b5444
...
...
@@ -117,7 +117,7 @@ def klass
# Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the
# through association's scope)
def
target_scope
AssociationRelation
.
new
(
klass
,
klass
.
arel_table
,
self
).
merge!
(
klass
.
all
)
AssociationRelation
.
create
(
klass
,
klass
.
arel_table
,
self
).
merge!
(
klass
.
all
)
end
# Loads the \target if needed and returns it.
...
...
activerecord/lib/active_record/associations/collection_association.rb
浏览文件 @
f38b5444
...
...
@@ -34,7 +34,7 @@ def reader(force_reload = false)
reload
end
@proxy
||=
CollectionProxy
.
new
(
klass
,
self
)
@proxy
||=
CollectionProxy
.
create
(
klass
,
self
)
end
# Implements the writer method, e.g. foo.items= for Foo.has_many :items
...
...
activerecord/lib/active_record/associations/join_dependency/join_association.rb
浏览文件 @
f38b5444
...
...
@@ -105,13 +105,13 @@ def join_constraints
if
item
.
is_a?
(
Relation
)
item
else
ActiveRecord
::
Relation
.
new
(
klass
,
table
).
instance_exec
(
self
,
&
item
)
ActiveRecord
::
Relation
.
create
(
klass
,
table
).
instance_exec
(
self
,
&
item
)
end
end
if
reflection
.
type
scope_chain_items
<<
ActiveRecord
::
Relation
.
new
(
klass
,
table
)
ActiveRecord
::
Relation
.
create
(
klass
,
table
)
.
where
(
reflection
.
type
=>
foreign_klass
.
base_class
.
name
)
end
...
...
activerecord/lib/active_record/associations/preloader.rb
浏览文件 @
f38b5444
...
...
@@ -85,7 +85,7 @@ class Preloader #:nodoc:
def
initialize
(
records
,
associations
,
preload_scope
=
nil
)
@records
=
Array
.
wrap
(
records
).
compact
.
uniq
@associations
=
Array
.
wrap
(
associations
)
@preload_scope
=
preload_scope
||
Relation
.
new
(
nil
,
nil
)
@preload_scope
=
preload_scope
||
Relation
.
create
(
nil
,
nil
)
end
def
run
...
...
activerecord/lib/active_record/core.rb
浏览文件 @
f38b5444
...
...
@@ -146,7 +146,7 @@ def arel_engine
private
def
relation
#:nodoc:
relation
=
Relation
.
new
(
self
,
arel_table
)
relation
=
Relation
.
create
(
self
,
arel_table
)
if
finder_needs_type_condition?
relation
.
where
(
type_condition
).
create_with
(
inheritance_column
.
to_sym
=>
sti_name
)
...
...
activerecord/lib/active_record/model_schema.rb
浏览文件 @
f38b5444
...
...
@@ -124,7 +124,7 @@ def table_name=(value)
@quoted_table_name
=
nil
@arel_table
=
nil
@sequence_name
=
nil
unless
defined?
(
@explicit_sequence_name
)
&&
@explicit_sequence_name
@relation
=
Relation
.
new
(
self
,
arel_table
)
@relation
=
Relation
.
create
(
self
,
arel_table
)
end
# Returns a quoted version of the table name, used to construct SQL statements.
...
...
activerecord/lib/active_record/relation/delegation.rb
浏览文件 @
f38b5444
...
...
@@ -73,10 +73,8 @@ def method_missing(method, *args, &block)
module
ClassMethods
# :nodoc:
@@subclasses
=
ThreadSafe
::
Cache
.
new
(
:initial_capacity
=>
2
)
def
new
(
klass
,
*
args
)
relation
=
relation_class_for
(
klass
).
allocate
relation
.
__send__
(
:initialize
,
klass
,
*
args
)
relation
def
create
(
klass
,
*
args
)
relation_class_for
(
klass
).
new
(
klass
,
*
args
)
end
# This doesn't have to be thread-safe. relation_class_for guarantees that this will only be
...
...
activerecord/lib/active_record/relation/merger.rb
浏览文件 @
f38b5444
...
...
@@ -22,7 +22,7 @@ def merge
# build a relation to merge in rather than directly merging
# the values.
def
other
other
=
Relation
.
new
(
relation
.
klass
,
relation
.
table
)
other
=
Relation
.
create
(
relation
.
klass
,
relation
.
table
)
hash
.
each
{
|
k
,
v
|
if
k
==
:joins
if
Hash
===
v
...
...
activerecord/lib/active_record/relation/spawn_methods.rb
浏览文件 @
f38b5444
...
...
@@ -64,7 +64,7 @@ def only(*onlies)
private
def
relation_with
(
values
)
# :nodoc:
result
=
Relation
.
new
(
klass
,
table
,
values
)
result
=
Relation
.
create
(
klass
,
table
,
values
)
result
.
extend
(
*
extending_values
)
if
extending_values
.
any?
result
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录