简体   繁体   English

Ruby On Rails ActiveRecord模型未显示“黑名单”字段

[英]Ruby On Rails ActiveRecord model not showing “blacklist” field

So I'm trying to rough out a design in Ruby, and so I ran 所以我试图在Ruby中粗略设计,所以我跑了

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

The only problem is that none of the bool fields are on the model. 唯一的问题是模型中没有布尔字段。 If I use ruby script/consol and run 如果我使用ruby脚本/ consol并运行

item = Item.new

I get 我懂了

#<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>

Is there a limit to how many fields it will show on the object? 它在对象上显示多少个字段是否有限制? I know the fields were created in the database... double checked that. 我知道字段是在数据库中创建的...再次检查。

Come to think of it the date timestamps aren't on the object either. 想到它,日期时间戳也不在对象上。 Any hints for me? 对我有什么提示吗? Do I have to manually write accessors for these or what? 我必须手动为这些写访问器还是什么?

Have you tried: 你有没有尝试过:

blacklist:boolean

It looks like you must declare the full name, the docs say: 看来您必须声明全名,文档说:

Instantiates a new column for the table. 实例化表的新列。 The type parameter is normally one of the migrations native types, which is one of the following: :primary_key , :string , :text , :integer , :float , :decimal , :datetime , :timestamp , :time , :date , :binary , :boolean . 类型参数通常是迁移本地类型,它是下列之一的一个: :primary_key:string:text:integer:float:decimal:datetime:timestamp:time:date:binary :boolean

Just like you cannot use int , you must declare integer 就像不能使用int ,必须声明integer

To answer the second part of your question, Yes! 要回答问题的第二部分, 是的! there is a limit to the number of columns you may have, 4096. 列数上限为4096。

It's likley that once the interpreter hit "bool" it nixed the latter column names and types, that is why you're probably missing your timestamps and what not. 很好的一点是,一旦解释器命中“ bool”,它就取消了后面的列名和类型,这就是为什么您可能会错过时间戳记而没有的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM