Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rendezvous
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
rendezvous
Commits
715625b7
Commit
715625b7
authored
Mar 11, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user recently post
parent
8aa14994
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
8 deletions
+20
-8
app/models/post.rb
+1
-1
app/models/user.rb
+6
-1
app/views/flow/show.html.slim
+13
-6
No files found.
app/models/post.rb
View file @
715625b7
...
@@ -2,7 +2,7 @@ class Post < ActiveRecord::Base
...
@@ -2,7 +2,7 @@ class Post < ActiveRecord::Base
has_many
:post_tags
has_many
:post_tags
has_many
:tags
,
through: :post_tags
has_many
:tags
,
through: :post_tags
belongs_to
:author
,
class_name:
'User'
belongs_to
:author
,
class_name:
'User'
has_many
:comments
has_many
:comments
,
inverse_of:
'posts'
default_scope
{
order
(
:updated_at
=>
:desc
)
}
default_scope
{
order
(
:updated_at
=>
:desc
)
}
...
...
app/models/user.rb
View file @
715625b7
...
@@ -7,9 +7,13 @@ class User < ActiveRecord::Base
...
@@ -7,9 +7,13 @@ class User < ActiveRecord::Base
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
devise
:omniauthable
,
omniauth_providers:
[
:google_oauth2
]
devise
:omniauthable
,
omniauth_providers:
[
:google_oauth2
]
has_many
:posts
has_many
:posts
,
foreign_key:
'author_id'
has_many
:comments
has_many
:comments
scope
:post_recently
,
->
{
User
.
joins
(
:posts
).
group
(
'id'
).
order
(
'posts.updated_at desc'
)
}
# Device
# Device
def
self
.
find_for_google_oauth2
(
access_token
,
signed_in_resource
=
nil
)
def
self
.
find_for_google_oauth2
(
access_token
,
signed_in_resource
=
nil
)
info
=
access_token
.
info
info
=
access_token
.
info
...
@@ -56,4 +60,5 @@ class User < ActiveRecord::Base
...
@@ -56,4 +60,5 @@ class User < ActiveRecord::Base
google_token_expires_at:
Time
.
now
+
res_json
[
'expires_in'
].
seconds
google_token_expires_at:
Time
.
now
+
res_json
[
'expires_in'
].
seconds
)
)
end
end
end
end
app/views/flow/show.html.slim
View file @
715625b7
/! view:flow/show
/! view:flow/show
.row
.row
h1
|
Flow
small
-
最近投稿された記事
.col-xs-8
role
=
"navigation"
.col-xs-8
role
=
"navigation"
#tab-list
.tab-pane.active
.list-group
.list-group
-
@posts
.
each_with_index
do
|
post
,
i
|
-
@posts
.
each_with_index
do
|
post
,
i
|
a
.list-group-item.post-list
data-post-id
=
post
.id
href
=
"#"
=
post
.
title
a
.list-group-item.post-list
data-post-id
=
post
.id
href
=
"#"
=
post
.
title
.col-xs-4
.col-xs-4
#list_post
h2
p
#posts-placeholder
style
=
"color:#aaa;font-size:30px"
<
--
Select
a
post
...
small
最近投稿したユーザー
.list-group
-
User
.
post_recently
.
limit
(
10
).
each_with_index
do
|
author
,
i
|
a
.list-group-item.post-list
data-author-id
=
author
.id
href
=
"#"
=
author
.
name
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