Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
18b1f171
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
18b1f171
编写于
6月 04, 2014
作者:
M
Marin Jankovski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename snippets scopes to plural names.
上级
84dc9cd6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
17 deletion
+17
-17
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+6
-6
app/models/snippet.rb
app/models/snippet.rb
+2
-2
app/views/snippets/current_user_index.html.haml
app/views/snippets/current_user_index.html.haml
+6
-6
config/initializers/state_machine_patch.rb
config/initializers/state_machine_patch.rb
+3
-3
未找到文件。
app/controllers/snippets_controller.rb
浏览文件 @
18b1f171
...
...
@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
layout
'navless'
def
index
@snippets
=
Snippet
.
is
_public
.
fresh
.
non_expired
.
page
(
params
[
:page
]).
per
(
20
)
@snippets
=
Snippet
.
are
_public
.
fresh
.
non_expired
.
page
(
params
[
:page
]).
per
(
20
)
end
def
user_index
...
...
@@ -26,15 +26,15 @@ class SnippetsController < ApplicationController
if
@user
==
current_user
@snippets
=
case
params
[
:scope
]
when
'
is
_public'
then
@snippets
.
is
_public
when
'
is
_private'
then
@snippets
.
is
_private
when
'
are
_public'
then
@snippets
.
are
_public
when
'
are
_private'
then
@snippets
.
are
_private
else
@snippets
end
else
@snippets
=
@snippets
.
is
_public
@snippets
=
@snippets
.
are
_public
end
@snippets
=
@snippets
.
page
(
params
[
:page
]).
per
(
20
)
...
...
app/models/snippet.rb
浏览文件 @
18b1f171
...
...
@@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base
validates
:content
,
presence:
true
# Scopes
scope
:
is
_public
,
->
{
where
(
private:
false
)
}
scope
:
is
_private
,
->
{
where
(
private:
true
)
}
scope
:
are
_public
,
->
{
where
(
private:
false
)
}
scope
:
are
_private
,
->
{
where
(
private:
true
)
}
scope
:fresh
,
->
{
order
(
"created_at DESC"
)
}
scope
:expired
,
->
{
where
([
"expires_at IS NOT NULL AND expires_at < ?"
,
Time
.
current
])
}
scope
:non_expired
,
->
{
where
([
"expires_at IS NULL OR expires_at > ?"
,
Time
.
current
])
}
...
...
app/views/snippets/current_user_index.html.haml
浏览文件 @
18b1f171
...
...
@@ -18,16 +18,16 @@
All
%span
.pull-right
=
@user
.
snippets
.
count
=
nav_tab
:scope
,
'
is
_private'
do
=
link_to
user_snippets_path
(
@user
,
scope:
'
is
_private'
)
do
=
nav_tab
:scope
,
'
are
_private'
do
=
link_to
user_snippets_path
(
@user
,
scope:
'
are
_private'
)
do
Private
%span
.pull-right
=
@user
.
snippets
.
is
_private
.
count
=
nav_tab
:scope
,
'
is
_public'
do
=
link_to
user_snippets_path
(
@user
,
scope:
'
is
_public'
)
do
=
@user
.
snippets
.
are
_private
.
count
=
nav_tab
:scope
,
'
are
_public'
do
=
link_to
user_snippets_path
(
@user
,
scope:
'
are
_public'
)
do
Public
%span
.pull-right
=
@user
.
snippets
.
is
_public
.
count
=
@user
.
snippets
.
are
_public
.
count
.col-md-9.my-snippets
=
render
'snippets'
...
...
config/initializers/state_machine_patch.rb
浏览文件 @
18b1f171
...
...
@@ -2,8 +2,8 @@
# where gem 'state_machine' was not working for Rails 4.1
module
StateMachine
module
Integrations
module
ActiveModel
public
:around_validation
end
module
ActiveModel
public
:around_validation
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录