![](/img/trans.png)
[英]Syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
[英]syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.' when I run rake db:migrate
當我運行rake db:migrate時出現語法錯誤,意外'\\ n',期待tCOLON2或'['或'。' 錯誤。請幫幫我
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string, :name
t.string, :email
t.string :login
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :login
t.timestamps
end
end
end
您已在字符串類型后輸入,這是唯一的語法錯誤。
刪除逗號並嘗試運行遷移。
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :login
t.timestamps
end
end
end
刪除不必要的逗號
您可能在生成模型或腳手架期間輸入了逗號
這應該是它的樣子
create_table :users do |t|
t.string :name
t.string :email
t.string :login
t.timestamps
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.