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 3 years have passed since last update.

[Rails]db:migrateの際に「private method `String' called ~ 」エラー

Last updated at Posted at 2020-12-24

##はじめに
マイグレート時に下記のエラーがでたので備忘録として書く

== 20~~~~~~~~~~~ CreateBoards: migrating =====================================
-- create_table(:boards)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

private method `String' called for 〜〜〜〜〜〜〜〜〜

マイグレーションファイル

class CreateBoards < ActiveRecord::Migration[6.0]
  def change
    create_table :boards do |t|
      t.String :title
      t.String :text

      t.timestamps
    end
  end
end

##対処方法
stringのSが大文字になっていると駄目らしい
小文字に修正して解決

class CreateBoards < ActiveRecord::Migration[6.0]
  def change
    create_table :boards do |t|
      t.string :title
      t.string :text

      t.timestamps
    end
  end
end

##参考
https://stackoverflow.com/questions/4003651/ruby-on-rails-rake-dbmigrate-error/4003717

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?