Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ddbeb15a
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,体验更适合开发者的 AI 搜索 >>
提交
ddbeb15a
编写于
5月 11, 2009
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Fixed bug with polymorphic has_one :as pointing to an STI record"
[#2594 state:open] This reverts commit
99c103be
.
上级
e1854e0b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
5 addition
and
21 deletion
+5
-21
activerecord/lib/active_record/associations/has_one_association.rb
...ord/lib/active_record/associations/has_one_association.rb
+1
-1
activerecord/test/cases/associations/has_one_associations_test.rb
...cord/test/cases/associations/has_one_associations_test.rb
+1
-8
activerecord/test/fixtures/organizations.yml
activerecord/test/fixtures/organizations.yml
+1
-3
activerecord/test/fixtures/sponsors.yml
activerecord/test/fixtures/sponsors.yml
+1
-3
activerecord/test/models/organization.rb
activerecord/test/models/organization.rb
+0
-4
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+1
-2
未找到文件。
activerecord/lib/active_record/associations/has_one_association.rb
浏览文件 @
ddbeb15a
...
...
@@ -90,7 +90,7 @@ def construct_sql
when
@reflection
.
options
[
:as
]
@finder_sql
=
"
#{
@reflection
.
quoted_table_name
}
.
#{
@reflection
.
options
[
:as
]
}
_id =
#{
owner_quoted_id
}
AND "
+
"
#{
@reflection
.
quoted_table_name
}
.
#{
@reflection
.
options
[
:as
]
}
_type =
#{
@owner
.
class
.
quote_value
(
@owner
.
class
.
name
.
to_s
)
}
"
"
#{
@reflection
.
quoted_table_name
}
.
#{
@reflection
.
options
[
:as
]
}
_type =
#{
@owner
.
class
.
quote_value
(
@owner
.
class
.
base_class
.
name
.
to_s
)
}
"
else
@finder_sql
=
"
#{
@reflection
.
quoted_table_name
}
.
#{
@reflection
.
primary_key_name
}
=
#{
owner_quoted_id
}
"
end
...
...
activerecord/test/cases/associations/has_one_associations_test.rb
浏览文件 @
ddbeb15a
...
...
@@ -2,11 +2,9 @@
require
'models/developer'
require
'models/project'
require
'models/company'
require
'models/sponsor'
require
'models/organization'
class
HasOneAssociationsTest
<
ActiveRecord
::
TestCase
fixtures
:accounts
,
:companies
,
:developers
,
:projects
,
:developers_projects
,
:organizations
,
:sponsors
fixtures
:accounts
,
:companies
,
:developers
,
:projects
,
:developers_projects
def
setup
Account
.
destroyed_account_ids
.
clear
...
...
@@ -308,9 +306,4 @@ def test_save_of_record_with_loaded_has_one
Firm
.
find
(
@firm
.
id
,
:include
=>
:account
).
save!
end
end
def
test_polymorphic_sti
assert_equal
organizations
(
:sponsorable
),
sponsors
(
:org_sponsor
).
sponsorable
assert_equal
sponsors
(
:org_sponsor
),
organizations
(
:sponsorable
).
sponsor
end
end
activerecord/test/fixtures/organizations.yml
浏览文件 @
ddbeb15a
...
...
@@ -2,6 +2,4 @@ nsa:
name
:
No Such Agency
discordians
:
name
:
Discordians
sponsorable
:
name
:
We Need Money
type
:
SponsorableOrganization
activerecord/test/fixtures/sponsors.yml
浏览文件 @
ddbeb15a
...
...
@@ -6,6 +6,4 @@ boring_club_sponsor_for_groucho:
sponsorable
:
some_other_guy (Member)
crazy_club_sponsor_for_groucho
:
sponsor_club
:
crazy_club
sponsorable
:
some_other_guy (Member)
org_sponsor
:
sponsorable
:
sponsorable (SponsorableOrganization)
\ No newline at end of file
sponsorable
:
some_other_guy (Member)
\ No newline at end of file
activerecord/test/models/organization.rb
浏览文件 @
ddbeb15a
class
Organization
<
ActiveRecord
::
Base
has_many
:member_details
has_many
:members
,
:through
=>
:member_details
end
class
SponsorableOrganization
<
Organization
has_one
:sponsor
,
:as
=>
:sponsorable
end
\ No newline at end of file
activerecord/test/schema/schema.rb
浏览文件 @
ddbeb15a
...
...
@@ -284,7 +284,6 @@ def create_table(*args, &block)
create_table
:organizations
,
:force
=>
true
do
|
t
|
t
.
string
:name
t
.
string
:type
end
create_table
:owners
,
:primary_key
=>
:owner_id
,
:force
=>
true
do
|
t
|
...
...
@@ -390,7 +389,7 @@ def create_table(*args, &block)
create_table
:sponsors
,
:force
=>
true
do
|
t
|
t
.
integer
:club_id
t
.
integer
:sponsorable_id
t
.
string
:sponsorable_type
t
.
string
:sponsorable_type
end
create_table
:subscribers
,
:force
=>
true
,
:id
=>
false
do
|
t
|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录