Commit d2746c40 by tady

post投稿にuser紐付け

parent 5b312688
......@@ -104,7 +104,7 @@
}
#post_preview {
min-height: 400px;
}
.editor {
......
......@@ -36,10 +36,11 @@ class PostsController < ApplicationController
# POST /posts.json
def create
@post = Post.new(post_params)
@post.author = current_user
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.html { redirect_to root_path(id: @post.id), notice: 'Post was successfully created.' }
format.json { render action: 'show', status: :created, location: @post }
else
format.html { render action: 'new' }
......@@ -53,7 +54,7 @@ class PostsController < ApplicationController
def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.html { redirect_to root_path(id: @post.id), notice: 'Post was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
......
......@@ -39,7 +39,7 @@
<div class="field">
<!-- <%= f.label :body %><br> -->
<%= f.text_area :body, class: 'autosize editor disable-tab', value: sample_body %>
<%= f.text_area :body, class: 'autosize editor disable-tab' %>
</div>
</div><!--/span-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment