views:

31

answers:

1

I have a DB table users that has the following columns: id, clan_id, experience

I want to run a query using rails that returns the top 50 clans based on experience. How would you do this query in rails?

Clan Table to User Table is a one to many relationship. Thus a clan is composed of multiple users that have the same id.

+2  A: 
Clan.find(:all, :order => "experience DESC", :limit => 50)
Toby Hede
clan table to user table is a one to many relationship. It is possible for a clan to have more than one user. I've updated the question to reflect this
Splashlin
This answer does exactly what you're looking for. You want 50 Clans sorted by `experience`. You should run the above query on the `Clan` model. The users table has nothing to do with your question whatsoever.
Ben
edited to explicitly use "clan" model
Toby Hede
Can you post the code that returns that error? Where is the path_revenue value coming from?
Toby Hede