0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Rails】tableのinsert処理でエラーが発生

Posted at

結論

class名が違った!!

原因

schema.rbのtable名からusers_controller.rbを作成し、エラー

schema.rb
create_table "users_test", force: :cascade do |t|
    t.string "name"
    ・・・
end
users_controller.rb エラー
def create
  @users_test = User_test.new
end

解決

models/user_test.rb内を確認すると下記のようになっていた

class UserTest < ApplicationRecord
end
users_controller.rb 修正後
def create
  @users_test = UserTest.new
end

修正後無事に解決。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?