轨生成模型字段:类型 - 什么是外地的选项:键入? [英] rails generate model field:type -what are the options for field:type?

查看:118
本文介绍了轨生成模型字段:类型 - 什么是外地的选项:键入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个愚蠢的问题,但像很多关于学习Rails的我找到的文档居然很难找到/导航。

我试图产生一种新的模式,而忘记了语法引用其他型号的ID。我想看看它自己,但还没想好,我的所有栏杆文档链接,如何找到可靠的信息源之一。

$导轨G型项目名称:字符串描述:文本(这里无论是参考:产品参考:产品)。但更好的问题是其中如何的我可以看看这种愚蠢的容易在未来,所以我不需要打扰你所有我的愚蠢的问题。

注:我已经学会了艰辛的道路,如果我输错其中的一个选项并运行我的迁移那么Rails会完全搞砸了我的数据库......和耙分贝:回滚是无能为力反对这样的screwups。我敢肯定,我只是不理解的东西,但直到我做......通过返回的详细的信息导轨G型仍然让我抓...

解决方案

 :primary_key,:字符串:文本,整数,:浮动,:小数:日期时间,:时间戳,
:时间:日期,:二进制:布尔,:引用
 

见<一href="http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column">table定义部分。

I know this is a silly question but like much about learning Rails I find the documentation incredibly difficult to find/navigate.

I'm trying to generate a new model and forget the syntax for referencing another model's ID. I'd look it up myself but haven't figured out, among all my rails documentation links, how to find the definitive source.

$ rails g model Item name:string description:text (and here either reference:product or references:product). But the better question is where or how can I look this kind of silliness easily in the future so I don't need to bother you all with my dumb questions.

Note: I've learned the hard way that if I mistype one of these options and run my migration then Rails will totally screw up my database... and rake db:rollback is powerless against such screwups. I'm sure I'm just not understanding something but until I do... the "detailed" information returned by rails g model still leaves me scratching...

解决方案

:primary_key, :string, :text, :integer, :float, :decimal, :datetime, :timestamp,
:time, :date, :binary, :boolean, :references

See the table definitions section.

这篇关于轨生成模型字段:类型 - 什么是外地的选项:键入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆