Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0405d5a7
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 搜索 >>
提交
0405d5a7
编写于
4月 12, 2014
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove branching logic from calls to find_nth
上级
fd56a78c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
6 deletion
+10
-6
activerecord/lib/active_record/relation/finder_methods.rb
activerecord/lib/active_record/relation/finder_methods.rb
+10
-6
未找到文件。
activerecord/lib/active_record/relation/finder_methods.rb
浏览文件 @
0405d5a7
...
...
@@ -131,7 +131,7 @@ def first(limit = nil)
if
limit
find_nth_with_limit
(
offset_value
,
limit
)
else
find_nth
(
:first
,
offset_
value
)
find_nth
(
:first
,
offset_
index
)
end
end
...
...
@@ -181,7 +181,7 @@ def last!
# Person.offset(3).second # returns the second object from OFFSET 3 (which is OFFSET 4)
# Person.where(["user_name = :u", { u: user_name }]).second
def
second
find_nth
(
:second
,
offset_
value
?
offset_value
+
1
:
1
)
find_nth
(
:second
,
offset_
index
+
1
)
end
# Same as +second+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
...
...
@@ -197,7 +197,7 @@ def second!
# Person.offset(3).third # returns the third object from OFFSET 3 (which is OFFSET 5)
# Person.where(["user_name = :u", { u: user_name }]).third
def
third
find_nth
(
:third
,
offset_
value
?
offset_value
+
2
:
2
)
find_nth
(
:third
,
offset_
index
+
2
)
end
# Same as +third+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
...
...
@@ -213,7 +213,7 @@ def third!
# Person.offset(3).fourth # returns the fourth object from OFFSET 3 (which is OFFSET 6)
# Person.where(["user_name = :u", { u: user_name }]).fourth
def
fourth
find_nth
(
:fourth
,
offset_
value
?
offset_value
+
3
:
3
)
find_nth
(
:fourth
,
offset_
index
+
3
)
end
# Same as +fourth+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
...
...
@@ -229,7 +229,7 @@ def fourth!
# Person.offset(3).fifth # returns the fifth object from OFFSET 3 (which is OFFSET 7)
# Person.where(["user_name = :u", { u: user_name }]).fifth
def
fifth
find_nth
(
:fifth
,
offset_
value
?
offset_value
+
4
:
4
)
find_nth
(
:fifth
,
offset_
index
+
4
)
end
# Same as +fifth+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
...
...
@@ -245,7 +245,7 @@ def fifth!
# Person.offset(3).forty_two # returns the fifth object from OFFSET 3 (which is OFFSET 44)
# Person.where(["user_name = :u", { u: user_name }]).forty_two
def
forty_two
find_nth
(
:forty_two
,
offset_
value
?
offset_value
+
41
:
41
)
find_nth
(
:forty_two
,
offset_
index
+
41
)
end
# Same as +forty_two+ but raises <tt>ActiveRecord::RecordNotFound</tt> if no record
...
...
@@ -334,6 +334,10 @@ def raise_record_not_found_exception!(ids, result_size, expected_size) #:nodoc:
private
def
offset_index
offset_value
||
0
end
def
find_with_associations
join_dependency
=
construct_join_dependency
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录