错误禁止保存此文章: 作者必须存在
我的article.rb代码
首先我创建文章表,然后创建作者表,然后我添加对文章的引用
我的article.rb代码
class Article < ApplicationRecord
belongs_to :category
belongs_to :author
end
Schema.rb
create_table "articles", force: :cascade do |t|
t.string "judul_artikel"
t.text "konten"
t.integer "category_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "authors_id"
t.index ["authors_id"], name: "index_articles_on_authors_id"
t.index ["category_id"], name: "index_articles_on_category_id"
end
create_table "authors", force: :cascade do |t|
t.string "author_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "categories", force: :cascade do |t|
t.string "nama_kategori"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
我只想创建文章,但没有错误。我该如何解决?