首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在Rails控制台中获得良好的格式

如何在Rails控制台中获得良好的格式
EN

Stack Overflow用户
提问于 2009-08-03 20:43:19
回答 9查看 70.2K关注 0票数 137

我想让这样的东西看起来更漂亮:

代码语言:javascript
复制
>> ProductColor.all
=> [#<ProductColor id: 1, name: "White", internal_name: "White", created_at: "2009-06-10 04:02:44", updated_at: "2009-06-10 04:02:44">, #<ProductColor id: 2, name: "Ivory", internal_name: "Ivory", created_at: "2009-06-10 04:02:44", updated_at: "2009-06-10 04:02:44">, #<ProductColor id: 3, name: "Blue", internal_name: "Light Blue", created_at: "2009-06-10 04:02:44", updated_at: "2009-06-10 04:02:44">, #<ProductColor id: 4, name: "Green", internal_name: "Green", created_at: "2009-06-10 04:02:44", updated_at: "2009-06-10 04:02:44">]

这不起作用:

代码语言:javascript
复制
>> ProductColor.all.inspect
=> "[#<ProductColor id: 1, name: \"White\", internal_name: \"White\", created_at: \"2009-06-10 04:02:44\", updated_at: \"2009-06-10 04:02:44\">, #<ProductColor id: 2, name: \"Ivory\", internal_name: \"Ivory\", created_at: \"2009-06-10 04:02:44\", updated_at: \"2009-06-10 04:02:44\">, #<ProductColor id: 3, name: \"Blue\", internal_name: \"Light Blue\", created_at: \"2009-06-10 04:02:44\", updated_at: \"2009-06-10 04:02:44\">, #<ProductColor id: 4, name: \"Green\", internal_name: \"Green\", created_at: \"2009-06-10 04:02:44\", updated_at: \"2009-06-10 04:02:44\">]"

这一点也不是:

代码语言:javascript
复制
>> ProductColor.all.to_yaml
=> "--- \n- !ruby/object:ProductColor \n  attributes: \n    name: White\n    created_at: 2009-06-10 04:02:44\n    updated_at: 2009-06-10 04:02:44\n    id: \"1\"\n    internal_name: White\n  attributes_cache: {}\n\n- !ruby/object:ProductColor \n  attributes: \n    name: Ivory\n    created_at: 2009-06-10 04:02:44\n    updated_at: 2009-06-10 04:02:44\n    id: \"2\"\n    internal_name: Ivory\n  attributes_cache: {}\n\n- !ruby/object:ProductColor \n  attributes: \n    name: Blue\n    created_at: 2009-06-10 04:02:44\n    updated_at: 2009-06-10 04:02:44\n    id: \"3\"\n    internal_name: Light Blue\n  attributes_cache: {}\n\n- !ruby/object:ProductColor \n  attributes: \n    name: Green\n    created_at: 2009-06-10 04:02:44\n    updated_at: 2009-06-10 04:02:44\n    id: \"4\"\n    internal_name: Green\n  attributes_cache: {}\n\n"

有什么想法?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1224525

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档