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 M.
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
On Mon, Sep 22, 2008 at 10:19 PM, Dan M. [email protected]
wrote:
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
–
Robby R.
Chief Evangelist, Partner
PLANET ARGON, LLC
design // development // hosting
http://www.robbyonrails.com/
aim: planetargon
+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]
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
–
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs