加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby on rails:如何为新模型创建表

发布时间:2020-12-16 21:50:28 所属栏目:百科 来源:网络整理
导读:我用 rails generate model mynewmodel string:name string:description 生成一个新的模型.如何将这个新模型部署到我的开发数据库?我已经在我的sqlite数据库中有一堆数据库. 我努力了 rake db:migrate 在db中生成这个新表似乎有麻烦. 更新:添加错误消息 ==
我用
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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读