Rabl allows you to grab the attributes by naming them in your view, for instance:
object @user
attributes :name, :email
I have a model whose attributes are will not be known, but I'd like to display everything returned from the controller in my instance variable using rabl.
Is there a shortcut like:
attributes :all
etc.
Thanks
You should be able to use .column_names
:
attributes *User.column_names
If you want to get rid of some columns, like "created_at" and "updated_at":
attributes *User.column_names - ["created_at", "updated_at"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With