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
5480173c
Commit
5480173c
authored
Mar 28, 2014
by
tady
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72 from tadyjp/wip/140328_post_date
postに日付追加
parents
80f1d343
094a33b1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
26 additions
and
11 deletions
+26
-11
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
+3
-2
No files found.
app/controllers/posts_controller.rb
View file @
5480173c
...
...
@@ -34,6 +34,7 @@ class PostsController < ApplicationController
# GET /posts/new
def
new
@post
=
Post
.
new
@post
.
title
=
'新しい投稿'
end
def
fork
...
...
@@ -126,13 +127,13 @@ class PostsController < ApplicationController
# Use callbacks to share common setup or constraints between actions.
def
set_post
@post
=
Post
.
find
(
params
[
:id
])
@post
=
Post
.
find
(
params
[
:id
])
.
decorate
end
# Never trust parameters from the scary internet, only allow the white list through.
def
post_params
@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
=
_param_hash
.
delete
(
'tags'
)
...
...
app/decorators/post_decorator.rb
View file @
5480173c
...
...
@@ -19,4 +19,12 @@ class PostDecorator < Draper::Decorator
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
app/views/flow/show.html.slim
View file @
5480173c
...
...
@@ -23,6 +23,6 @@
h2
.panel-title
最近投稿したユーザー(調整中)
.panel-body.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
=
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 @
5480173c
...
...
@@ -9,7 +9,7 @@
-
@post
.
errors
.
full_messages
.
each
do
|
msg
|
li
=
msg
.row
.col-xs-
10
.col-xs-
9
.field
.input-group
span
.input-group-addon
=
f
.
label
:title
...
...
@@ -20,12 +20,14 @@
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
(
','
)
.col-xs-
2
.col-xs-
3
p
.actions
=
f
.
submit
class:
'btn btn-primary js-disable-confirm-unload'
,
id:
'save_button'
p
.actions
=
f
.
check_box
:is_draft
=
f
.
label
:is_draft
,
"下書き保存"
p
.actions
=
f
.
date_select
:specified_date
br
/
.row
...
...
app/views/posts/_show_fragment.html.slim
View file @
5480173c
...
...
@@ -12,7 +12,7 @@
a
href
=
(
posts_path
(
q:
"@
#{
@post
.
author
.
name
}
"
)
)
|
@
#{
@post
.
author
.
name
}
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;"
)
a
.btn.btn-primary
href
=
edit_post_path
(
@post
)
span
.glyphicon.glyphicon-pencil
...
...
app/views/posts/edit.html.slim
View file @
5480173c
h1
編集
=
render
'form'
app/views/posts/new.html.slim
View file @
5480173c
h1
新しい投稿
=
render
'form'
app/views/tags/events.json.jbuilder
View file @
5480173c
json.array!(@tag.posts) do |post|
json.extract! post, :title
json.url post_url(post)
json.start post.created_at
json.start post.
specified_date || post.
created_at
end
db/migrate/20140328045902_add_specified_date_to_posts.rb
0 → 100644
View file @
5480173c
class
AddSpecifiedDateToPosts
<
ActiveRecord
::
Migration
def
change
add_column
:posts
,
:specified_date
,
:date
end
end
db/schema.rb
View file @
5480173c
...
...
@@ -11,7 +11,7 @@
#
# 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
|
t
.
integer
"author_id"
...
...
@@ -40,7 +40,8 @@ ActiveRecord::Schema.define(version: 20140320043116) do
t
.
integer
"author_id"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
boolean
"is_draft"
,
default:
false
t
.
boolean
"is_draft"
,
default:
false
t
.
date
"specified_date"
end
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