I am making an Instagram like website using ruby on rails. So far everything is good except for my destroy controller when I try to delete one of my posts, it shows me this error:
SQLite3::SQLException: no such column: posts.post_id: SELECT “posts”.* FROM “posts” WHERE “posts”.“post_id” = ?
class PostsController < ApplicationController before_action :set_post, only: [:show, :edit, :update, :destroy] def index @posts = Post.all end def show end def new @post = Post.new end def create if @post = Post.create(post_params) flash[:success] = "Your post has been created!" redirect_to posts_path else flash.now[:alert] = "Your new post couldn't be created! Please check the form." render :new end end def edit end def update if @post.update(post_params) flash[:success] = "Post updated." redirect_to posts_path else flash.now[:alert] = "Update failed. Please check the form." render :edit end end def destroy @post.destroy redirect_to root_path end private def post_params params.require(:post).permit(:image, :caption) end def set_post @post = Post.find(params[:id]) end end
If there is any other code needed to be seen I will happily edit my question. Thank you.