SQLite3 :: SQLException:没有这样的专栏:reviews.restaurant_id:SELECT" reviews"。* FROM" reviews"在哪里"评论"。" restaurant_id" =? 提取的来源(第91行):
def prepare sql
stmt = SQLite3::Statement.new( self, sql )
return stmt unless block_given?
begin
class Review < ApplicationRecord
belongs_to :user
belongs_to :restaurant
end
class Restaurant < ApplicationRecord
has_many :reviews
has_many :users, through: :reviews
end
class User < ApplicationRecord
has_many :reviews
has_many :restaurants, through: :reviews
end
ActiveRecord::Schema.define(version: 20170420034712) do
create_table "restaurants", force: :cascade do |t|
t.string "logo"
t.string "name"
t.text "description"
t.string "address1"
t.string "address2"
t.string "city"
t.string "state"
t.string "zipcode"
t.string "phone"
t.integer "cost"
t.integer "rating"
t.string "menu"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "reviews", force: :cascade do |t|
t.text "comment"
t.integer "rating"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.integer "num_visits"
t.integer "num_searches"
t.integer "num_called"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
所以我使用Rails管理员我可以将项目添加到数据库但是我无法删除它们或通过Rails管理员编辑它们。我想知道我是否遗漏了一些简单的东西。我认为我可以在创建后删除或编辑用户或餐馆。我不太了解错误,也无法找到相关文档。任何帮助将不胜感激。