Skip to content

How to sort/alter order of attributes based on options/params. #355

Answered by okuramasafumi
marvfinsy asked this question in Q&A
Discussion options

You must be logged in to vote

@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:

class SomeResource
  include Alba::Resource
  def attributes
    super.sort # Or sort as you like
  end
end

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@marvfinsy
Comment options

Answer selected by okuramasafumi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants