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
094a33b1
Commit
094a33b1
authored
Mar 28, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
postに日付追加
parent
80f1d343
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
25 additions
and
10 deletions
+25
-10
app/controllers/posts_controller.rb
+3
-2
app/decorators/post_decorator.rb
+8
-0
app/views/flow/show.html.slim
+1
-1
app/views/posts/_form.html.slim
+4
-2
app/views/posts/_show_fragment.html.slim
+1
-1
app/views/posts/edit.html.slim
+0
-1
app/views/posts/new.html.slim
+0
-1
app/views/tags/events.json.jbuilder
+1
-1
db/migrate/20140328045902_add_specified_date_to_posts.rb
+5
-0
db/schema.rb
+2
-1
No files found.
app/controllers/posts_controller.rb
View file @
094a33b1
...
@@ -34,6 +34,7 @@ class PostsController < ApplicationController
...
@@ -34,6 +34,7 @@ class PostsController < ApplicationController
# GET /posts/new
# GET /posts/new
def
new
def
new
@post
=
Post
.
new
@post
=
Post
.
new
@post
.
title
=
'新しい投稿'
end
end
def
fork
def
fork
...
@@ -126,13 +127,13 @@ class PostsController < ApplicationController
...
@@ -126,13 +127,13 @@ class PostsController < ApplicationController
# Use callbacks to share common setup or constraints between actions.
# Use callbacks to share common setup or constraints between actions.
def
set_post
def
set_post
@post
=
Post
.
find
(
params
[
:id
])
@post
=
Post
.
find
(
params
[
:id
])
.
decorate
end
end
# Never trust parameters from the scary internet, only allow the white list through.
# Never trust parameters from the scary internet, only allow the white list through.
def
post_params
def
post_params
@post_params
||=
begin
@post_params
||=
begin
_param_hash
=
params
.
require
(
:post
).
permit
(
:title
,
:body
,
:tags
,
:is_draft
).
to_hash
_param_hash
=
params
.
require
(
:post
).
permit
(
:title
,
:body
,
:tags
,
:is_draft
,
:specified_date
).
to_hash
# tags_text == 'Javascript,Ruby'
# tags_text == 'Javascript,Ruby'
tags_text
=
_param_hash
.
delete
(
'tags'
)
tags_text
=
_param_hash
.
delete
(
'tags'
)
...
...
app/decorators/post_decorator.rb
View file @
094a33b1
...
@@ -19,4 +19,12 @@ class PostDecorator < Draper::Decorator
...
@@ -19,4 +19,12 @@ class PostDecorator < Draper::Decorator
end
end
end
end
def
display_date
if
model
.
specified_date
model
.
specified_date
.
strftime
(
'%Y-%m-%d'
)
else
model
.
updated_at
.
strftime
(
'%Y-%m-%d'
)
end
end
end
end
app/views/flow/show.html.slim
View file @
094a33b1
...
@@ -23,6 +23,6 @@
...
@@ -23,6 +23,6 @@
h2
.panel-title
最近投稿したユーザー(調整中)
h2
.panel-title
最近投稿したユーザー(調整中)
.panel-body.list-group
.panel-body.list-group
-
User
.
post_recently
.
limit
(
10
).
each_with_index
do
|
author
,
i
|
-
User
.
post_recently
.
limit
(
10
).
each_with_index
do
|
author
,
i
|
a
.list-group-item.post-list
data-author-id
=
author
.id
href
=
search_path
(
q:
"@
#{
author
.
nickname
}
"
)
=
author
.
name
a
.list-group-item.post-list
data-author-id
=
author
.id
href
=
search_path
(
q:
"@
#{
author
.
nickname
}
"
)
=
"
#{
author
.
name
}
(@
#{
author
.
nickname
}
)"
app/views/posts/_form.html.slim
View file @
094a33b1
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
-
@post
.
errors
.
full_messages
.
each
do
|
msg
|
-
@post
.
errors
.
full_messages
.
each
do
|
msg
|
li
=
msg
li
=
msg
.row
.row
.col-xs-
10
.col-xs-
9
.field
.field
.input-group
.input-group
span
.input-group-addon
=
f
.
label
:title
span
.input-group-addon
=
f
.
label
:title
...
@@ -20,12 +20,14 @@
...
@@ -20,12 +20,14 @@
span
.input-group-addon
=
f
.
label
:tags
span
.input-group-addon
=
f
.
label
:tags
=
hidden_field
:post
,
:tags
,
class:
'mod-mdEditor-tags'
,
style:
'width:300px'
,
value:
@post
.
tags
.
map
{
|
_tag
|
_tag
.
name
}.
join
(
','
)
=
hidden_field
:post
,
:tags
,
class:
'mod-mdEditor-tags'
,
style:
'width:300px'
,
value:
@post
.
tags
.
map
{
|
_tag
|
_tag
.
name
}.
join
(
','
)
.col-xs-
2
.col-xs-
3
p
.actions
p
.actions
=
f
.
submit
class:
'btn btn-primary js-disable-confirm-unload'
,
id:
'save_button'
=
f
.
submit
class:
'btn btn-primary js-disable-confirm-unload'
,
id:
'save_button'
p
.actions
p
.actions
=
f
.
check_box
:is_draft
=
f
.
check_box
:is_draft
=
f
.
label
:is_draft
,
"下書き保存"
=
f
.
label
:is_draft
,
"下書き保存"
p
.actions
=
f
.
date_select
:specified_date
br
/
br
/
.row
.row
...
...
app/views/posts/_show_fragment.html.slim
View file @
094a33b1
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
a
href
=
(
posts_path
(
q:
"@
#{
@post
.
author
.
name
}
"
)
)
a
href
=
(
posts_path
(
q:
"@
#{
@post
.
author
.
name
}
"
)
)
|
@
#{
@post
.
author
.
name
}
|
@
#{
@post
.
author
.
name
}
span
.label.label-danger
span
.label.label-danger
a
href
=
(
posts_path
(
q:
"date:
#{
@post
.
updated_at
.
strftime
(
'%Y-%m-%d'
)
}"))
=
@post
.
updated_at
.
strftime
(
'%Y-%m-%d'
)
a
href
=
(
posts_path
(
q:
"date:
#{
@post
.
display_date
}
"
)
)
=
@post
.
display_date
.btn-group.pull-right
style
=
(
"margin: -7px -12px 0 0;"
)
.btn-group.pull-right
style
=
(
"margin: -7px -12px 0 0;"
)
a
.btn.btn-primary
href
=
edit_post_path
(
@post
)
a
.btn.btn-primary
href
=
edit_post_path
(
@post
)
span
.glyphicon.glyphicon-pencil
span
.glyphicon.glyphicon-pencil
...
...
app/views/posts/edit.html.slim
View file @
094a33b1
h1
編集
=
render
'form'
=
render
'form'
app/views/posts/new.html.slim
View file @
094a33b1
h1
新しい投稿
=
render
'form'
=
render
'form'
app/views/tags/events.json.jbuilder
View file @
094a33b1
json.array!(@tag.posts) do |post|
json.array!(@tag.posts) do |post|
json.extract! post, :title
json.extract! post, :title
json.url post_url(post)
json.url post_url(post)
json.start post.created_at
json.start post.
specified_date || post.
created_at
end
end
db/migrate/20140328045902_add_specified_date_to_posts.rb
0 → 100644
View file @
094a33b1
class
AddSpecifiedDateToPosts
<
ActiveRecord
::
Migration
def
change
add_column
:posts
,
:specified_date
,
:date
end
end
db/schema.rb
View file @
094a33b1
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2014032
0043116
)
do
ActiveRecord
::
Schema
.
define
(
version:
2014032
8045902
)
do
create_table
"comments"
,
force:
true
do
|
t
|
create_table
"comments"
,
force:
true
do
|
t
|
t
.
integer
"author_id"
t
.
integer
"author_id"
...
@@ -41,6 +41,7 @@ ActiveRecord::Schema.define(version: 20140320043116) do
...
@@ -41,6 +41,7 @@ ActiveRecord::Schema.define(version: 20140320043116) do
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
boolean
"is_draft"
,
default:
false
t
.
boolean
"is_draft"
,
default:
false
t
.
date
"specified_date"
end
end
add_index
"posts"
,
[
"is_draft"
],
name:
"index_posts_on_is_draft"
,
using: :btree
add_index
"posts"
,
[
"is_draft"
],
name:
"index_posts_on_is_draft"
,
using: :btree
...
...
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