Commit d2746c40 by tady

post投稿にuser紐付け

parent 5b312688
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
} }
#post_preview { #post_preview {
min-height: 400px;
} }
.editor { .editor {
......
...@@ -36,10 +36,11 @@ class PostsController < ApplicationController ...@@ -36,10 +36,11 @@ class PostsController < ApplicationController
# POST /posts.json # POST /posts.json
def create def create
@post = Post.new(post_params) @post = Post.new(post_params)
@post.author = current_user
respond_to do |format| respond_to do |format|
if @post.save 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 } format.json { render action: 'show', status: :created, location: @post }
else else
format.html { render action: 'new' } format.html { render action: 'new' }
...@@ -53,7 +54,7 @@ class PostsController < ApplicationController ...@@ -53,7 +54,7 @@ class PostsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @post.update(post_params) 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 } format.json { head :no_content }
else else
format.html { render action: 'edit' } format.html { render action: 'edit' }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<div class="field"> <div class="field">
<!-- <%= f.label :body %><br> --> <!-- <%= 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>
</div><!--/span--> </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