@user = User.new @post = user.post.build
とすると以下のエラーがでます。
unknown attribute 'user_id' for Post.
なぜ出るのでしょうか。
schema.rb
で以下のように記述しています。
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.string "user_serial", null: false end
create_table "posts", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.string "content" t.string "content_path" t.string "reply_token", null: false t.bigint "user_id" t.index ["user_id"], name: "index_posts_on_user_id" end
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/08/29 03:09