Rails模型types列表
是否有人在生成模型脚手架时指定了完整的模型types列表
例如
foo:string bar:text baz:boolean
等等…
这些types在默认UI元素方面是如何映射的? 文本字段,文本区域,单选button,checkbox等…
属性是SQLtypes,因此支持以下内容:
-
:binary -
:boolean -
:date -
:datetime -
:decimal -
:float -
:integer -
:primary_key -
:string -
:text -
:time -
:timestamp
这些logging在Active Record API的 栏目下。
您可以在模型脚手架中使用以下基本字段types,所有在ActiveRecord支持的数据库中都不受任何额外gem支持(MySQL,PostgreSQL,SQLite):
-
:binary -
:boolean -
:date -
:datetime -
:decimal -
:float -
:integer -
:primary_key -
:string -
:text -
:time -
:timestamp
在脚手架生成器中,您还可以使用:references字段types来声明外部引用,该:references字段types在新模型中添加了belongs_to引用。
如果你使用Rails 4和PostgreSQL,你可以利用这些:
-
:hstore -
:array -
:cidr_address -
:ip_address -
:mac_address
对于UI映射(模型脚手架数据types – > HTML),下一个图像具有所有基本字段types:
