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
b930d512
Commit
b930d512
authored
Mar 18, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下書き保存機能
parent
3f0451f8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
10 deletions
+29
-10
app/controllers/flow_controller.rb
+1
-1
app/controllers/posts_controller.rb
+1
-1
app/models/post.rb
+1
-1
app/views/posts/_form.html.slim
+15
-6
db/migrate/20140318040809_add_is_draft_to_posts.rb
+7
-0
db/schema.rb
+4
-1
No files found.
app/controllers/flow_controller.rb
View file @
b930d512
...
...
@@ -2,6 +2,6 @@ class FlowController < ApplicationController
before_action
:require_login
def
show
@posts
=
Post
.
order
(
updated_at: :desc
).
limit
(
20
).
decorate
@posts
=
Post
.
where
(
is_draft:
false
).
order
(
updated_at: :desc
).
limit
(
20
).
decorate
end
end
app/controllers/posts_controller.rb
View file @
b930d512
...
...
@@ -132,7 +132,7 @@ class PostsController < ApplicationController
# 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
).
to_hash
_param_hash
=
params
.
require
(
:post
).
permit
(
:title
,
:body
,
:tags
,
:is_draft
).
to_hash
# tags_text == 'Javascript,Ruby'
tags_text
=
_param_hash
.
delete
(
'tags'
)
...
...
app/models/post.rb
View file @
b930d512
...
...
@@ -4,7 +4,7 @@ class Post < ActiveRecord::Base
belongs_to
:author
,
class_name:
'User'
has_many
:comments
default_scope
{
order
(
:updated_at
=>
:desc
)
}
# default_scope { where(is_draft: false).
order(:updated_at => :desc) }
# Named scope
scope
:search
,
(
lambda
do
|
query
|
...
...
app/views/posts/_form.html.slim
View file @
b930d512
...
...
@@ -14,17 +14,18 @@
.input-group
span
.input-group-addon
=
f
.
label
:title
=
f
.
text_field
:title
,
class:
'form-control mod-mdEditor-title'
.col-xs-2
.actions
=
f
.
submit
class:
'btn btn-primary js-disable-confirm-unload'
,
id:
'save_button'
.row
.col-xs-8
.field
.input-group
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-4
.col-xs-2
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
,
"下書き保存"
br
/
.row
...
...
@@ -36,6 +37,7 @@
.text-box.body.viewer.github.mod-mdEditor-preview
input
#fileupload
data-url
=
"/apis/file_receiver"
multiple
=
""
name
=
"files[]"
style
=
"display:none"
type
=
"file"
/
-
content_for
:footer_js
do
javascript:
$
.
setConfirmUnload
();
...
...
@@ -46,3 +48,10 @@ input#fileupload data-url="/apis/file_receiver" multiple="" name="files[]" style
$input
:
$
(
'#fileupload'
),
$textarea
:
$
(
'.mod-mdEditor-body'
)
});
// 下書き保存
$
(
'.btn-save-draft'
).
on
(
'click'
,
function
(
e
){
e
.
preventDefault
();
var
val
=
$
(
'.mod-mdEditor-body'
).
val
();
console
.
log
(
val
);
});
db/migrate/20140318040809_add_is_draft_to_posts.rb
0 → 100644
View file @
b930d512
class
AddIsDraftToPosts
<
ActiveRecord
::
Migration
def
change
add_column
:posts
,
:is_draft
,
:boolean
,
default:
false
add_index
:posts
,
:is_draft
end
end
db/schema.rb
View file @
b930d512
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201403
02053916
)
do
ActiveRecord
::
Schema
.
define
(
version:
201403
18040809
)
do
create_table
"comments"
,
force:
true
do
|
t
|
t
.
integer
"author_id"
...
...
@@ -40,8 +40,11 @@ ActiveRecord::Schema.define(version: 20140302053916) do
t
.
integer
"author_id"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
boolean
"is_draft"
,
default:
false
end
add_index
"posts"
,
[
"is_draft"
],
name:
"index_posts_on_is_draft"
,
using: :btree
create_table
"tags"
,
force:
true
do
|
t
|
t
.
string
"name"
t
.
datetime
"created_at"
...
...
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