[英]Ruby on Rails scaffolding error
我正在嘗試使用以下命令來搭建模型:
rails generate scaffold Ofertruck title:string country:string city:string lwh:string comment:text postalcode:integer weigth:decimal
我在遷移文件中得到的結果如下:
class CreateOfertrucks < ActiveRecord::Migration
def change
create_table :ofertrucks do |t|
t.string :title
t.string city :country
t.decimal :weigth
t.timestamps null: false
end
end
end
它生成的內容是錯誤的,並且將由捆綁程序執行rake db:migrate給出錯誤
有可能在網上看到
t.string city :country
為什么會這樣生成,因為我確保在每個數據庫列之間都留一個空格?
它沒有給我一個錯誤,可能是您在某個地方鍵入錯誤。
首先刪除它:
#destroy
rails d scaffold Ofertruck title:string country:string city:string lwh:string comment:text postalcode:integer weigth:decimal
試試這個:
# Generate again
rails g scaffold ofertruck title country city lwh comment:text postalcode:integer weigth:decimal
#
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.