Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5153c0c2
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 搜索 >>
提交
5153c0c2
编写于
7月 15, 2017
作者:
K
Kasper Timm Hansen
提交者:
GitHub
7月 15, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29679 from kamipo/add_test_case_for_27724
Add a test case for overwriting existing condition on associations
上级
a07ddbf5
d3303c31
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
0 deletion
+12
-0
activerecord/test/cases/associations/has_many_through_associations_test.rb
.../cases/associations/has_many_through_associations_test.rb
+7
-0
activerecord/test/models/post.rb
activerecord/test/models/post.rb
+5
-0
未找到文件。
activerecord/test/cases/associations/has_many_through_associations_test.rb
浏览文件 @
5153c0c2
...
...
@@ -946,6 +946,13 @@ def test_can_update_through_association
end
end
def
test_has_many_through_polymorphic_with_rewhere
post
=
TaggedPost
.
create!
(
title:
"Tagged"
,
body:
"Post"
)
tag
=
post
.
tags
.
create!
(
name:
"Tag"
)
assert_equal
[
tag
],
TaggedPost
.
preload
(
:tags
).
last
.
tags
assert_equal
[
tag
],
TaggedPost
.
eager_load
(
:tags
).
last
.
tags
end
def
test_has_many_through_polymorphic_with_primary_key_option
assert_equal
[
categories
(
:general
)],
authors
(
:david
).
essay_categories
...
...
activerecord/test/models/post.rb
浏览文件 @
5153c0c2
...
...
@@ -199,6 +199,11 @@ class FirstPost < ActiveRecord::Base
has_one
:comment
,
foreign_key: :post_id
end
class
TaggedPost
<
Post
has_many
:taggings
,
->
{
rewhere
(
taggable_type:
"TaggedPost"
)
},
as: :taggable
has_many
:tags
,
through: :taggings
end
class
PostWithDefaultInclude
<
ActiveRecord
::
Base
self
.
inheritance_column
=
:disabled
self
.
table_name
=
"posts"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录