我找到这样的东西:
Rails: How to list database tables/objects using the Rails console?
这条线很好:
ActiveRecord::Base.connection.tables
并返回所有表
但
ActiveRecord::Base.connection.table_structure("users")
ActiveRecord::Base.connection.table_structure("projects")
我觉得
table_structure
不是Postgres方法.
解决方法
您可以直接从命令行从postgres获取此信息
psql your_development_database -c "\d" -- lists all database tables psql your_development_database -c "\d users" -- lists all columns for a table; 'users' in this case
如果要查看rails控制台中的Model属性
User.new User.new.inspect # or install the awesome_print gem for better output ap User.new
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。