ActiveRecord and SELECT AS SQL statements?

How about: ranked_users = User. All :order => 'users. Points then in your view you can say % @ranked_users.

Each_with_index do |user, index| %.

How about: @ranked_users = User. All :order => 'users. Points' then in your view you can say if for some reason you need to keep that numeric index in the database, you'll need to add an after_save callback to update the full list of users whenever the # of points anyone has changes.

You might look into using the acts_as_list plugin to help out with that, or that might be total overkill.

Try adding user_rank to your model. Class User ) end end Then you can access it with @user.rank.

What if you did: SELECT t1. User_id, COUNT(t1. Points) FROM registrations t1 GROUP BY t1.

User_id ORDER BY COUNT(t1. Points) DESC If you want to get all rails-y, then do cool_users = self. Find_by_sql '(sql above)' cool_users.

Each do |cool_user| puts "#{cool_user0} scores #{cool_user1}" end.

Find_by_sql 'SELECT t1. Points) as user_rank FROM registrations as t1, registrations as t2 WHERE t1. Points Points OR (t1.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send