The way to implement arrays in ActiveRecord is via has_many.
But, normally Ruby arrays keep the order of elements, while has_many do
not.
This is not just a matter of “order by” clause.
At every update one needs to index database table rows properly, so that
“order by” would work.
You have to add an index column and use order by. SQL as a standard does
not guarantee any ordering unless you enforce it, so any implementation
can
return elements in the order that is most efficient.
Can you give us more information on what is in your array and for what
reason they are sorted? Someone may be able to suggest a better
solution to the problem.
Please quote the relevant parts of previous message when posting, this
is a mailing list not a forum (though you may be accessing it via a
forum-like interface) so it is not always obvious which message you
are replying to. Thanks.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.