LoginSignup
4
0

More than 5 years have passed since last update.

->> rake db:migrate rake aborted! SyntaxError: : syntax error, unexpected '\n', expecting :: or '[' or '.'

Posted at

表題のエラーが

rake db:migrate

で発生

これは下記で実行すると発生します。

rails g model study te:string, page:integer, title:string

カンマが紛れていますこれでファイルを作成すると下記のようになります。

class CreateStudies < ActiveRecord::Migration[5.0]
  def change
    create_table :studies do |t|
      t.string, :te
      t.integer, :page
      t.string :title

      t.timestamps
    end
  end
end

t.string, :te <- 左記のようにカンマが紛れています。

これを修正します。

class CreateStudies < ActiveRecord::Migration[5.0]
  def change
    create_table :studies do |t|
      t.string :te
      t.integer :page
      t.string :title

      t.timestamps
    end
  end
end

このように修正すると成功します。

->> rake db:migrate
== 20180201081725 CreateStudies: migrating ====================================
-- create_table(:studies)
   -> 0.0204s
== 20180201081725 CreateStudies: migrated (0.0205s) ===========================


4
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
4
0