![](/img/trans.png)
[英]When does the comment block with schema information for the model get updated by rails?
[英]Can I get the comment information from a rails active model?
我正在使用ruby和activerecord获取有关列的信息。
我可以使用以下方法获取列类型和其他信息:
Product.table_name
Product.column_names
Product.columns_hash['title'].type
我的迁移脚本如下:
create_table :products do |t|
t.string :title, :comment => "Product's title name"
end
我如何获得标题的comment ("Product's title name"
)
如果您正在谈论新的Rails 5列注释功能 ,则应该可以致电
Product.columns_hash['title'].comment
获取在迁移中定义的注释。 有关更多用法示例,请参见Rails源代码中的此测试 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.