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
9f411a7e
Commit
9f411a7e
authored
May 02, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
headerの通知view作成
parent
188e5d3b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
5 deletions
+44
-5
app/controllers/notifications_controller.rb
+15
-0
app/models/notification.rb
+18
-0
app/views/partials/_app_header.html.slim
+9
-5
config/routes.rb
+2
-0
No files found.
app/controllers/notifications_controller.rb
0 → 100644
View file @
9f411a7e
class
NotificationsController
<
ApplicationController
before_action
:set_notification
,
only:
[
:bridge
]
def
bridge
@notification
.
set_read!
redirect_to
@notification
.
detail_path
end
private
def
set_notification
@notification
=
Notification
.
find
(
params
[
:id
])
end
end
app/models/notification.rb
View file @
9f411a7e
class
Notification
<
ActiveRecord
::
Base
class
Notification
<
ActiveRecord
::
Base
belongs_to
:user
belongs_to
:user
######################################################################
# Named scope
######################################################################
# 最新のPostを取得
scope
:unread
,
->
{
where
(
is_read:
false
)
}
######################################################################
# Instance method
######################################################################
# 既読にする
def
set_read!
update!
(
is_read:
true
,
read_at:
Time
.
now
)
end
end
end
app/views/partials/_app_header.html.slim
View file @
9f411a7e
...
@@ -44,14 +44,18 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
...
@@ -44,14 +44,18 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
li
.dropdown
li
.dropdown
a
.dropdown-toggle
data-toggle
=
"dropdown"
a
.dropdown-toggle
data-toggle
=
"dropdown"
|
通知
|
通知
span
.badge
=
current_user
.
decorate
.
draft_count
-
if
current_user
.
notifications
.
unread
.
any?
span
.badge
=
current_user
.
notifications
.
unread
.
count
b
.caret
b
.caret
ul
.dropdown-menu
ul
.dropdown-menu
-
current_user
.
notifications
.
each
do
|
notification
|
-
if
current_user
.
notifications
.
unread
.
any?
-
current_user
.
notifications
.
unread
.
each
do
|
notification
|
li
a
href
=
notification_bridge_path
(
notification
.
id
)
=
notification
.
body
-
else
li
li
a
href
=
notification
.detail_path
a
通知はありません
=
notification
.
body
span
.badge.pull-right
=
current_user
.
decorate
.
draft_count
config/routes.rb
View file @
9f411a7e
...
@@ -18,6 +18,8 @@ Rendezvous::Application.routes.draw do
...
@@ -18,6 +18,8 @@ Rendezvous::Application.routes.draw do
get
'posts/:id/slideshow'
=>
'posts#slideshow'
,
as:
'slideshow_post'
get
'posts/:id/slideshow'
=>
'posts#slideshow'
,
as:
'slideshow_post'
resources
:posts
,
except:
[
:index
]
resources
:posts
,
except:
[
:index
]
get
'notification_bridge/:id'
=>
'notifications#bridge'
,
as:
'notification_bridge'
post
'tags/:name/merge_to/:merge_to_name'
=>
'tags#merge_to'
,
as:
'merge_to_tag'
post
'tags/:name/merge_to/:merge_to_name'
=>
'tags#merge_to'
,
as:
'merge_to_tag'
post
'tags/:name/move_to/:move_to_name'
=>
'tags#move_to'
,
as:
'move_to_tag'
post
'tags/:name/move_to/:move_to_name'
=>
'tags#move_to'
,
as:
'move_to_tag'
resources
:tags
,
:param
=>
:name
,
except:
[
:index
]
resources
:tags
,
:param
=>
:name
,
except:
[
:index
]
...
...
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