Ruby on rails RABL-通配符包括所有属性

Ruby on rails RABL-通配符包括所有属性,ruby-on-rails,ruby,rabl,Ruby On Rails,Ruby,Rabl,有没有可能在RABL模板中使用某种通配符,它将收回模型的所有可访问属性,而不必指定每个属性 例如,RABL文档显示了如下内容,其中返回了:id、:title、:subject属性 # app/views/posts/index.rabl collection @posts attributes :id, :title, :subject child(:user) { attributes :full_name } node(:read) { |post| post.read_by?(@user)

有没有可能在RABL模板中使用某种通配符,它将收回模型的所有可访问属性,而不必指定每个属性

例如,RABL文档显示了如下内容,其中返回了
:id、:title、:subject
属性

# app/views/posts/index.rabl
collection @posts
attributes :id, :title, :subject
child(:user) { attributes :full_name }
node(:read) { |post| post.read_by?(@user) }
我想做一些类似的事情

# app/views/posts/index.rabl
collection @posts
attributes *
child(:user) { attributes :full_name }
node(:read) { |post| post.read_by?(@user) }

让这个给你一个id,标题,主题,作者,等等,你应该能够做到这一点

attributes *Post.column_names

Model.column\u names
返回所有列的数组,前面的星号将其转换为逗号分隔的参数。

谢谢。当我读到你的答案时,我(字面上)把脸捂住了。