Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change the order of the nodes? #60

Closed
millisami opened this issue Jul 8, 2011 · 2 comments
Closed

How to change the order of the nodes? #60

millisami opened this issue Jul 8, 2011 · 2 comments

Comments

@millisami
Copy link

Here is my rabl view.

collection @lines => :lines
attributes :title, :description
code :id do |line|
  line.account.name+"-"+line.title
end

and the response is:

{"lines"=>
  [{"title"=>"private-line", "description"=>"Et pariatur eos eaquptas enim.", "id"=>"wliTa-private-line"}, 
   {"title"=>"public-line", "description"=>"This line can be viewed publicly", "id"=>"wliTa-public-line"}]
}

I want the id attribute to be at first attribute like below:

{"lines"=>
  [{"id"=>"wliTa-private-line", "title"=>"private-line", "description"=>"Et pariatur quae voluptas enim."}, 
  {"id"=>"wliTa-public-line", "title"=>"public-line", "description"=>"This line can be viewed publicly"}]
}

Is this doable or any other solution to get this order of response?

@nesquena
Copy link
Owner

nesquena commented Jul 8, 2011

There is not a way to control the order of the nodes in RABL since a hash is by nature unordered. I am curious also, why does the order of the nodes matter?

@millisami
Copy link
Author

I was just trying to match the documentation with the response so I was looking for the exact order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants