Commit 83eeba1b authored by John Noel's avatar John Noel

Added Post update function

parent 3251579f
...@@ -36,6 +36,15 @@ class PostsController < ApplicationController ...@@ -36,6 +36,15 @@ class PostsController < ApplicationController
@post = Post.find_by(id: params[:id]) @post = Post.find_by(id: params[:id])
end end
def update
@post = Post.find_by(id: params[:id])
if @post.update(post_params)
redirect_to posts_path, notice: "You have successfully updated a post."
else
render 'edit'
end
end
private private
def post_params def post_params
params.require(:post).permit! params.require(:post).permit!
......
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