title: Rails Redis Leaderboard
body: <p>I am developing leaderboard application in Rails using Leaderboard gem. I am storing my data in postgres and using the same for usage with Redis. Currently the output iam getting is array of hashes:</p>
  
  <pre><code>[{:member=&gt;"Elinor", :rank=&gt;1, :score=&gt;993.0}, {:member=&gt;"Glennie", :rank=&gt;2, :score=&gt;986.0}, {:member=&gt;"Dudley", :rank=&gt;3, :score=&gt;982.0}, {:member=&gt;"Aashish", :rank=&gt;4, :score=&gt;900.0}, {:member=&gt;"Daron", :rank=&gt;5, :score=&gt;899.0}, {:member=&gt;"Telly", :rank=&gt;6, :score=&gt;878.0}, {:member=&gt;"Lois", :rank=&gt;7, :score=&gt;828.0}, {:member=&gt;"Aaron", :rank=&gt;8, :score=&gt;825.0}, {:member=&gt;"Rosa", :rank=&gt;9, :score=&gt;819.0}, {:member=&gt;"Gaylord", :rank=&gt;10, :score=&gt;795.0}, {:member=&gt;"Enrico", :rank=&gt;11, :score=&gt;790.0}, {:member=&gt;"Fabiola", :rank=&gt;12, :score=&gt;788.0}, {:member=&gt;"Orville", :rank=&gt;13, :score=&gt;778.0}, {:member=&gt;"Christiana", :rank=&gt;14, :score=&gt;768.0}, {:member=&gt;"Whitney", :rank=&gt;15, :score=&gt;753.0}, {:member=&gt;"Lera", :rank=&gt;16, :score=&gt;750.0}, {:member=&gt;"Manuel", :rank=&gt;17, :score=&gt;749.0}, {:member=&gt;"Eli", :rank=&gt;18, :score=&gt;737.0}, {:member=&gt;"Keshawn", :rank=&gt;19, :score=&gt;722.0}, {:member=&gt;"Bernadine", :rank=&gt;20, :score=&gt;718.0}, {:member=&gt;"Aliza", :rank=&gt;21, :score=&gt;675.0}, {:member=&gt;"Hermann", :rank=&gt;22, :score=&gt;622.0}, {:member=&gt;"Reina", :rank=&gt;23, :score=&gt;606.0}, {:member=&gt;"Emmy", :rank=&gt;24, :score=&gt;552.0}, {:member=&gt;"John", :rank=&gt;25, :score=&gt;541.0}, {:member=&gt;"Mohamed", :rank=&gt;26, :score=&gt;538.0}, {:member=&gt;"Summer", :rank=&gt;27, :score=&gt;523.0}, {:member=&gt;"Brooks", :rank=&gt;28, :score=&gt;521.0}, {:member=&gt;"Lorenz", :rank=&gt;29, :score=&gt;476.0}, {:member=&gt;"Pink", :rank=&gt;30, :score=&gt;431.0}, {:member=&gt;"Frances", :rank=&gt;31, :score=&gt;401.0}, {:member=&gt;"Ervin", :rank=&gt;32, :score=&gt;387.0}, {:member=&gt;"Rubye", :rank=&gt;33, :score=&gt;374.0}, {:member=&gt;"Neoma", :rank=&gt;34, :score=&gt;350.0}, {:member=&gt;"Jaunita", :rank=&gt;35, :score=&gt;348.0}, {:member=&gt;"Jessie", :rank=&gt;36, :score=&gt;315.0}, {:member=&gt;"Joyce", :rank=&gt;37, :score=&gt;298.0}, {:member=&gt;"Samantha", :rank=&gt;38, :score=&gt;290.0}, {:member=&gt;"Jackson", :rank=&gt;39, :score=&gt;266.0}, {:member=&gt;"Spencer", :rank=&gt;40, :score=&gt;257.0}, {:member=&gt;"Adrianna", :rank=&gt;41, :score=&gt;254.0}, {:member=&gt;"Myrtice", :rank=&gt;42, :score=&gt;238.0}, {:member=&gt;"Hannah", :rank=&gt;43, :score=&gt;236.0}, {:member=&gt;"Carrie", :rank=&gt;44, :score=&gt;233.0}, {:member=&gt;"Marlee", :rank=&gt;45, :score=&gt;218.0}, {:member=&gt;"Nyasia", :rank=&gt;46, :score=&gt;207.0}, {:member=&gt;"Jennie", :rank=&gt;47, :score=&gt;201.0}, {:member=&gt;"Kristy", :rank=&gt;48, :score=&gt;185.0}, {:member=&gt;"Kristofer", :rank=&gt;49, :score=&gt;149.0}, {:member=&gt;"Gonzalo", :rank=&gt;50, :score=&gt;131.0}, {:member=&gt;"Lacey", :rank=&gt;51, :score=&gt;128.0}, {:member=&gt;"member_10", :rank=&gt;52, :score=&gt;10.0}, {:member=&gt;"member_9", :rank=&gt;53, :score=&gt;9.0}, {:member=&gt;"member_8", :rank=&gt;54, :score=&gt;8.0}, {:member=&gt;"member_7", :rank=&gt;55, :score=&gt;7.0}, {:member=&gt;"member_6", :rank=&gt;56, :score=&gt;6.0}, {:member=&gt;"member_5", :rank=&gt;57, :score=&gt;5.0}, {:member=&gt;"member_4", :rank=&gt;58, :score=&gt;4.0}, {:member=&gt;"member_3", :rank=&gt;59, :score=&gt;3.0}, {:member=&gt;"84849296", :rank=&gt;60, :score=&gt;3.0}, {:member=&gt;"member_2", :rank=&gt;61, :score=&gt;2.0}, {:member=&gt;"84849294", :rank=&gt;62, :score=&gt;2.0}, {:member=&gt;"member_1", :rank=&gt;63, :score=&gt;1.0}, {:member=&gt;"84849297", :rank=&gt;64, :score=&gt;1.0}, {:member=&gt;"84849295", :rank=&gt;65, :score=&gt;1.0}, {:member=&gt;"84849293", :rank=&gt;66, :score=&gt;1.0}, {:member=&gt;"84849292", :rank=&gt;67, :score=&gt;1.0}]
  </code></pre>
  
  <p>I tried converting it into json and as per the documentation but still the response is not converted. </p>
  
  <p>My show method in controller is below:</p>
  
  <pre><code>def show
    setredis 
    @users = User.all
    @users.each do|f|  
    name = f.name
    score = f.score
    @highscore_lb.rank_member(name, score).to_json
  end
  </code></pre>
  
  <p>setredis method</p>
  
  <pre><code>def setredis
    redis_options = {:host =&gt; '127.0.0.1', :port =&gt; 6379, :db =&gt; 1}
  @highscore_lb = Leaderboard.new('highscores', Leaderboard::DEFAULT_OPTIONS, redis_options)
  
  end
  </code></pre>
  
  <p>I tried using each loop as well , still the data is not being parsed. Any help would be appreciated. 
  Thanks</p>