How can i make ActiveRecord find in order for an array parameter?
Ex. for Test.find([1, 2, 3, 4, 5]) it should return test.id=1 as the first entry.
Right, it just returns in a random order.
thanks
How can i make ActiveRecord find in order for an array parameter?
Ex. for Test.find([1, 2, 3, 4, 5]) it should return test.id=1 as the first entry.
Right, it just returns in a random order.
thanks
You'll need to use the :order option. Test.find([1,2,3,4,5], :order => "id")
-Dan Manges http://www.dcmanges.com/blog
Assuming that you're trying to order them by the id, you can sort the array when you pass it into .find.
Test.find( array_name.sort )
Good luck!
Cheers, Robby
wheels wrote:
How can i make ActiveRecord find in order for an array parameter?
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/158dc2d879b2fb1