【发布时间】:2020-03-08 07:15:36
【问题描述】:
我是 Rails 新手,正在尝试制作一个简单的网络应用程序。
我生成了以下组件:
rails generate scaffold user username:string password:string
rails generate scaffold appointment doctor:references patient:references
在预约模型中,我将医生和病人的类指定为如下用户
# app/models/appointment.rb
class Appointment < ApplicationRecord
belongs_to :doctor, :class_name => "User"
belongs_to :patient, :class_name => "User"
end
我让其他一切保持不变,通过应用 rails db:migrate 和 rake db:test:prepare,我收到一条错误消息,说我没有桌子医生
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: main.doctors
但我认为 modify.rb 中的规范会为我完成这项工作。
我该如何进行这项工作?
【问题讨论】:
标签: ruby-on-rails ruby