开发者

Retrieving Rails Model Column Names

开发者 https://www.devze.com 2023-02-16 14:24 出处:网络
When one 开发者_JAVA技巧retrieves a Rails model object, how are the column (or object attribute) names accessed?User.column_names

When one 开发者_JAVA技巧retrieves a Rails model object, how are the column (or object attribute) names accessed?


User.column_names

Like a lot of things in Rails, it just works :)


Example:

user = User.find(1)
p user.attributes.keys
0

精彩评论

暂无评论...
验证码 换一张
取 消