Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
18b1f171
Commit
18b1f171
authored
Jun 04, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename snippets scopes to plural names.
parent
84dc9cd6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
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
No files found.
app/controllers/snippets_controller.rb
View file @
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
View file @
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
View file @
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'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment