mysql - How to store each record or row in descending order into database in rails? -


i want store record or row in descending order of scores of match database in ruby on rails. can top 3 topper rank of current user. don't know how this.

the problem simple: don't need specify order when insert data in database. database engine capable of sorting data according instructions when perform select.

simply create rails model store score , reference of subject associated score (e.g. user_id).

then, solution selecting records ordering score. assuming model called result

result.order("score desc").limit(3) 

just small note. simple problem, long have necessary basic knowledge of ruby, rails , database interaction.

this answer helpful if do. if don't, you'll need start simpler problems learn these topics first.


Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -