2010-02-26 54 views
0

所以我想在Ruby中粗糙了设计,所以我跑Ruby on Rails的ActiveRecord的模型没有显示“黑名单”字段

ruby script/generate scaffold item name:string description:text model:string manufacturers_name:string category:string weight:decimal upc:string ebay_cat_id:string blacklist:bool in_discovery:bool archived:bool 

唯一的问题是,没有一个布尔值字段是上该模型。如果我使用Ruby脚本/拼箱和运行

item = Item.new 

我得到

#<Item id: nil, name: nil, description: nil, model: nil, manufacturers_name: nil, category: nil, weight: nil, upc: nil, ebay_cat_id: nil, created_at: nil, updated_at: nil> 

是否有将有多少个字段显示对象上的限制吗?我知道这些字段是在数据库中创建的...双重检查。

想想吧,日期时间戳也不在对象上。对我有什么提示?我是否必须手动为这些或者什么写入访问器?

回答

2

你试过:

blacklist:boolean 

看起来你必须声明的全名,该文件说:

实例化的表中的新列。类型参数通常是迁移本地类型,它是下列之一的一个::primary_key:string:text:integer:float:decimal:datetime:timestamp:time:date:binary:boolean

就像你不能用int,您必须声明integer

要回答你的问题,是第二部分!可能有4096列的数量是有限制的。

它很可能一旦解释器击中了“bool”,它将忽略后面的列名和类型,这就是为什么你可能会错过时间戳和什么不是。

+0

谢谢...猜我刚刚错过了。再次感谢。 – Boushley 2010-02-26 05:41:49

+0

对我来说,它似乎很奇怪,它只是静静地死去......或者有没有记录我只是不检查? – Boushley 2010-02-26 06:00:33