简体   繁体   English

Rails:如何找出活动记录中的字段

[英]Rails: How do I find out what fields are in an active record

I've got an active record class open. 我有一个活跃的记录课开放。 I want to know all the fields available to me in that class? 我想知道那堂课中我可以使用的所有领域吗?
How can I do this quickly, without walking over to the database design document hanging on my wall? 如何快速完成此操作,而无需走到挂在墙上的数据库设计文档中?

I'm trying to wrap my head around having public data elements, obfuscated from me, but I just find it so frustrating to get at the field names available. 我正试图将公共数据元素包裹起来,对我进行模糊处理,但我发现获得字段名称非常令人沮丧。

也许Model.attribute_names正是你要找的。

注释宝石非常适合这种情况。

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

相关问题 如何让 Rails Active Record Association 问题文本以嵌套形式显示空答案字段? - How do I get Rails Active Record Association question text to show with empty answer fields in nested form? 在 Rails 中,如何从 Active Record 左连接表中打印出 user.name - In Rails, how do I print out a user.name from an Active Record left join table 如何从Rails活动记录中返回查询,以便可以将它们传递回客户端日志控制台 - How do I return queries out of Rails active record so I can pass them back to a client-side log console 在Rails 5中,如何迭代活动记录集? - In Rails 5, how do I iterate over an active record set? 我怎么能做这样的事情? on rails 活动记录 - How can I do something like this? on rails active record 如何在Rails / Active Record中保存关联的对象 - How do i save an associated Object in Rails / Active Record 如何从现有的 Rails 7 站点中删除活动记录? - How do I remove active record from an existing rails 7 site? 如何使Rails识别活动记录的正确ID? - How do I make rails recognize a correct id of an active record? Rails和Active Record:如何访问同级关联? - Rails & Active Record: How do I access a sibling association? Rails API 如何发送活动记录验证错误? - Rails API how do I send the active record validation error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM