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
188e5d3b
Commit
188e5d3b
authored
May 01, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create notifications table
parent
09d06742
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
1 deletions
+53
-1
app/models/notification.rb
+3
-0
app/models/user.rb
+5
-0
app/views/partials/_app_header.html.slim
+12
-0
db/migrate/20140501045300_create_notifications.rb
+15
-0
db/schema.rb
+13
-1
spec/models/notification_spec.rb
+5
-0
No files found.
app/models/notification.rb
0 → 100644
View file @
188e5d3b
class
Notification
<
ActiveRecord
::
Base
belongs_to
:user
end
app/models/user.rb
View file @
188e5d3b
...
...
@@ -37,6 +37,7 @@ class User < ActiveRecord::Base
######################################################################
has_many
:posts
,
foreign_key:
'author_id'
has_many
:comments
,
foreign_key:
'author_id'
has_many
:notifications
######################################################################
# scope
...
...
@@ -105,6 +106,10 @@ class User < ActiveRecord::Base
)
end
# push通知を追加
def
push_notification
(
detail_path
,
body
)
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
end
end
app/views/partials/_app_header.html.slim
View file @
188e5d3b
...
...
@@ -41,5 +41,17 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
li
.divider
li
a
href
=
me_session_path
data-method
=
"delete"
rel
=
"nofollow"
SignOut
li
.dropdown
a
.dropdown-toggle
data-toggle
=
"dropdown"
|
通知
span
.badge
=
current_user
.
decorate
.
draft_count
b
.caret
ul
.dropdown-menu
-
current_user
.
notifications
.
each
do
|
notification
|
li
a
href
=
notification
.detail_path
=
notification
.
body
span
.badge.pull-right
=
current_user
.
decorate
.
draft_count
db/migrate/20140501045300_create_notifications.rb
0 → 100644
View file @
188e5d3b
class
CreateNotifications
<
ActiveRecord
::
Migration
def
change
create_table
:notifications
do
|
t
|
t
.
integer
:user_id
t
.
datetime
:read_at
t
.
boolean
:is_read
,
null:
false
,
default:
false
t
.
string
:detail_path
t
.
text
:body
t
.
timestamps
end
add_index
:notifications
,
[
:user_id
,
:is_read
,
:read_at
]
end
end
db/schema.rb
View file @
188e5d3b
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20140
420120819
)
do
ActiveRecord
::
Schema
.
define
(
version:
20140
501045300
)
do
create_table
"comments"
,
force:
true
do
|
t
|
t
.
integer
"author_id"
...
...
@@ -24,6 +24,18 @@ ActiveRecord::Schema.define(version: 20140420120819) do
add_index
"comments"
,
[
"author_id"
,
"updated_at"
],
name:
"index_comments_on_author_id_and_updated_at"
,
using: :btree
add_index
"comments"
,
[
"post_id"
,
"updated_at"
],
name:
"index_comments_on_post_id_and_updated_at"
,
using: :btree
create_table
"notifications"
,
force:
true
do
|
t
|
t
.
integer
"user_id"
t
.
datetime
"read_at"
t
.
boolean
"is_read"
,
default:
false
,
null:
false
t
.
string
"detail_path"
t
.
text
"body"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
add_index
"notifications"
,
[
"user_id"
,
"is_read"
,
"read_at"
],
name:
"index_notifications_on_user_id_and_is_read_and_read_at"
,
using: :btree
create_table
"post_tags"
,
force:
true
do
|
t
|
t
.
integer
"post_id"
,
null:
false
t
.
integer
"tag_id"
,
null:
false
...
...
spec/models/notification_spec.rb
0 → 100644
View file @
188e5d3b
require
'spec_helper'
describe
Notifications
do
pending
"add some examples to (or delete)
#{
__FILE__
}
"
end
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