Forum: Ruby on Rails How can I get posted params in correct order?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8b777217583ebf095420de3364236ccb?d=identicon&s=25 Heikki Ylönen (heikki)
on 2006-05-04 14:12
I'd like to have posted form field data in the same order they were in
the form.
Raw_post shows the data in correct order but params hash doesn't. This
happens every time (tried it with webrick).

Any ideas how to get an array of objects in the correct order?
8b777217583ebf095420de3364236ccb?d=identicon&s=25 Heikki Ylönen (heikki)
on 2006-05-04 14:25
.. just realized that nested objects make correct ordering difficult.
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-05-04 14:28
(Received via mailing list)
Heikki Ylönen wrote:
> I'd like to have posted form field data in the same order they were in
> the form.
> Raw_post shows the data in correct order but params hash doesn't. This
> happens every time (tried it with webrick).
>
> Any ideas how to get an array of objects in the correct order?
Unfortunately, that's just a side-effect of the fact that hashes in Ruby
don't preserve order.  As far as I know, your options are to name your
fields in alphanumerical order so that you can do a
params.keys.sort.each {}, to keep an array with the keys in the right
order in the controller, or to manually parse them out of the raw_post.
  None of these is particularly fantastic...
This topic is locked and can not be replied to.