It shows nascargurly with 30 intelligence higher than nascargurly48
with 90 intelligence when it should be the other way around. Its like
its ordering by the way things are added to array then by the order of
intelligence. I added nascargurly to the website after nascargurly48.
the command prompt says its ordering by intelligence but the array
doesnt show it. Any ideas?

On Oct 14, 8:52 am, Pamela <[email protected]> wrote:
> hey, so I put the code in my website and this is what it outputted for
> me. I used ranked_players[0] and so on to get the output.
>
> 1. nascargurly with 30 intelligence     1. nascargurly48 with 30
> creativity      1. nascargurly48 with 10 strength       1. nascargurly48 with 
> 10
> charisma        1. nascargurly48 with 30 technological
> 2       2. nascargurly48 with 90 intelligence   2. nascargurly with 30
> creativity      2. nascargurly with 10 strength 2. nascargurly with 10
> charisma        2. nascargurly with 90 technological
>
> On Oct 12, 10:06 am, Pamela <[email protected]> wrote:
>
>
>
> > Thanks you guys for the responses. I greatly appreciate it. I am going
> > to implement this into my website and see how it works. thanks. : )
>
> > On Oct 12, 2:18 am, Kalastiuz <[email protected]> wrote:
>
> > > I'm sorry. Of course `|player, index|` it's my misprint
>
> > > On Wed, Oct 12, 2011 at 6:34 AM, Roy Situmorang 
> > > <[email protected]>wrote:
>
> > > > Correction:
> > > > ranked_players = Array.new
> > > > Player.all(:order => 'intelligence').each_with_index do |player, index|
> > > >   ranked_players << "#{index + 1}. #{player[:name]} with
> > > > #{player[:intelligence]} intelligence"
> > > > end
>
> > > > #now you have ranked players list
> > > > ranked_players.each do |player|
> > > >   puts player
> > > > end
>
> > > > On Tue, Oct 11, 2011 at 8:49 PM, Kalastiuz <[email protected]> wrote:
>
> > > >> what if:
> > > >> ranked_players = Array.new
> > > >> Player.all(:order => 'intelligence').each_with_index do |player|
> > > >>   ranked_players << "#{index + 1}. #{player[:name]} with
> > > >> #{player[:intelligence]} intelligence"
> > > >> end
>
> > > >> #now you have ranked players list
> > > >> ranked_players.each do |player|
> > > >>   puts player
> > > >> end
>
> > > >> On Mon, Oct 10, 2011 at 11:33 PM, Pamela <[email protected]> wrote:
>
> > > >>> I am making a browser-based game using ruby on rails and I am having
> > > >>> trouble implementing a ranking system for my game. Each player has
> > > >>> five skills: intelligence, creativity, strength, charisma and
> > > >>> technological. I want the player to have a rank for each skill. The
> > > >>> ranking I have in place right now gives the same rank if two players
> > > >>> have the same amount of skill.
>
> > > >>> SELECT COUNT(*) AS [rank] FROM players "+
> > > >>>    "WHERE intelligence >= "+
> > > >>>    "(SELECT intelligence FROM players WHERE id = #[email protected]})
>
> > > >>> I want each player to have a different rank even if they have the same
> > > >>> amount of skill as another player but I can't seem to figure out how
> > > >>> to implement that. I have an intelligence column and an irank column,
> > > >>> the same for the rest of the skills, and I was thinking that I could
> > > >>> first sort the intelligence column and then according to that sorting
> > > >>> assign a number to the irank column from 1 and so on but I can't
> > > >>> figure out how to exactly implement this. I was thinking maybe a for
> > > >>> loop or a .each do loop but I hit a roadblock. I know I can do
> > > >>> Player.all(:order => 'intelligence DESC') to sort it but after that
> > > >>> I'm stumped.
>
> > > >>> I would appreciate any hints or help that anyone could provide me if
> > > >>> willing. Thanks.
>
> > > >>> --
> > > >>> You received this message because you are subscribed to the Google 
> > > >>> Groups
> > > >>> "Ruby on Rails: Talk" group.
> > > >>> To post to this group, send email to 
> > > >>> [email protected].
> > > >>> To unsubscribe from this group, send email to
> > > >>> [email protected].
> > > >>> For more options, visit this group at
> > > >>>http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > > >>  --
> > > >> You received this message because you are subscribed to the Google 
> > > >> Groups
> > > >> "Ruby on Rails: Talk" group.
> > > >> To post to this group, send email to [email protected].
> > > >> To unsubscribe from this group, send email to
> > > >> [email protected].
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > > >  --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "Ruby on Rails: Talk" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected].
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to