Rails rabl - returns ALL attributes, not just names

Rabl allows you to capture attributes by naming them in your view, for example:

object @user attributes :name, :email 

I have a model whose attributes will not be known, but I would like to display everything returned from the controller in my instance variable using rabl.

Is there a shortcut, for example:

 attributes :all 

and etc.

thanks

+6
source share
2 answers

You can use .column_names :

 attributes *User.column_names 
+21
source

If you want to get rid of some columns, such as "created_at" and "updated_at":

 attributes *User.column_names - ["created_at", "updated_at"] 
+5
source

All Articles