I am working on creating a small rails app, and I have ran into a problem that I believe is in the backend of my database, but I don't know how to solve it. Ultimately what is happening is if I try to go to my my new
url, I get an error stating PG::UndefinedTable: ERROR: relation "caves" does not exist LINE 8: WHERE a.attrelid = '"caves"'::regclass
All I am trying to do us create a new cafe
I go to localhost:3000/cafes/new
but for some really annoying reason, caves somehow somewhere got in the mix and I don't know how to get around this.
My controller is essentially below. (the rest of the items in my controller are empty methods at this point)
def new
@cafe = Cafe.new
end
def create
@cafe = Cafe.new(cafe_params)
end
private
def cafe_params
params.require(:name, :description)
end
My schema table is
enable_extension "plpgsql"
create_table "cafes", force: :cascade do |t|
t.string "name"
t.text "description"
end
create_table "users", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.string "email"
t.integer "age"
end
I have two empty models right now one called user.rb
and the other cafe.rb
This is where I get really confused because there is no cave relation in my model.
class Cafe < ApplicationRecord
end
Thats about where I am. Would anyone know what I could do with this? I'm thinking that possibly there is a duplicate database somewhere and it needs to be destroyed. I've tried a rake db:drop
+ rake db:create
+ rake db:migrate
route with what I have, but no luck. I know there is a way to open up my database through straight up psql, and I think that may be the way into really truly debugging this problem. (i've seen it done once, but don't remember how to do it, let alone only know active record, not sql)
Does anyone know whats going on here? Or does anyone know how to get into psql and how to find something like this?
I really do appreciate it.
Aucun commentaire:
Enregistrer un commentaire