mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
Add new post form
This commit is contained in:
20
app/controllers/posts_controller.rb
Normal file
20
app/controllers/posts_controller.rb
Normal 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
|
||||
Reference in New Issue
Block a user