Add new post form

This commit is contained in:
riggraz
2019-09-02 14:32:57 +02:00
parent 4cb60cf2ed
commit edacfb1a4f
16 changed files with 397 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
class PostsController < ApplicationController
before_action :authenticate_user!
def create
post = Post.new(post_params)
post.user_id = current_user.id
if post.save
render json: { status: 'success' }
else
render json: { status: 'error', message: post.errors.full_messages }
end
end
private
def post_params
params.require(:post).permit(:title, :description, :board_id)
end
end