我用
rails generate model mynewmodel string:name string:description
生成一个新模型。如何将这个新模型部署到我的开发数据库中?我的 sqlite 数据库中已经有一堆数据库。
我试过了
rake db:migrate
在 db 中生成这个新表似乎有问题。
更新:添加了错误信息
== CreateMynewmodels: migrating ===============================================
-- create_table(:mynewmodels)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `name' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x3ad5c50>
Tasks: TOP => db:migrate
谢谢
最佳答案
您的字段名:类型组合的顺序不正确。尝试
rails generate model mynewmodel name:string description:string
关于轨道上的 ruby : How to create table for a new model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13483051/