Files
astuto/app/controllers/posts_controller.rb
2019-09-02 14:32:57 +02:00

21 lines
433 B
Ruby

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