just want my first ten parts of the hash? how to chop it?

Something like this should do it:

@temp = Articles.find(:all, :order => 'articles.rating desc', :limit => 10)

It's much faster to combine the sorting with the database query than to pull all the records and sort them in code.

Aaron

Hi --

So the rating is stored in another table. In that case you want to do a SQL join that combines Articles with Ratings. Just add a :include to your find statement like this:

@temp = Articles.find(:all, :order => 'ratings_table_name.rating desc', :limit => 10, :include => :rating)

One thing that can be a little confusing is that the :order parameter requires the name of the table you are referring to, while :include references the name of the model association. That's because the :order parameter gets dropped right into the SQL statement while the :include is processed by rails and converted into SQL.

Aaron