轨生成模型字段:类型 - 什么是外地的选项:键入?字段、外地、选项、模型

由网友(愚人自娱)分享简介:我知道这是一个愚蠢的问题,但像很多关于学习Rails的我找到的文档居然很难找到/导航。 我试图产生一种新的模式,而忘记了语法引用其他型号的ID。我想看看它自己,但还没想好,我的所有栏杆文档链接,如何找到可靠的信息源之一。$导轨G型项目名称:字符串描述:文本(这里无论是参考:产品或参考:产品)。但更好的问题是其中或如何的...

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

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

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

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

解决方案

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

见table定义部分。

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

dedeCMS自定义模型字段内页和首页调用方法

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.

阅读全文

相关推荐

最新文章