The edit
action is not visible as it is private
and is not executed. Hence @post
is nil
. Move it above the private
call
def edit
@post = Post.find(params[:id])
end
private
def post_params
params.require(:post).permit(:title, :content)
end