How to sort/alter order of attributes based on options/params. #355
-
Need way to filter attributes returned and modify order of attributes. I can see how to possibly do filtering but see no way to alter order of attributes. |
Beta Was this translation helpful? Give feedback.
Answered by
okuramasafumi
Jan 3, 2024
Replies: 1 comment 1 reply
-
@marvfinsy class SomeResource
include Alba::Resource
def attributes
super.sort # Or sort as you like
end
end |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
okuramasafumi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@marvfinsy
For filtering, you can see https://github.com/okuramasafumi/alba?tab=readme-ov-file#filtering-attributes.
For modifying the order of attributes, I believe you can override
attributes
instance method like below: