本文介绍了ActiveRecord的:表从控制台名单列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,你可以问ActiveRecord的列出使用表中控制台:

I know that you can ask ActiveRecord to list tables in console using:

ActiveRecord::Base.connection.tables

是否有一个命令,将列出列在一个给定的表?

Is there a command that would list the columns in a given table?

推荐答案

这将列出column_names从表

This will list the column_names from a table

Model.column_names
e.g. User.column_names

这篇关于ActiveRecord的:表从控制台名单列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 21:56