Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:23:25+00:00 2026-06-04T04:23:25+00:00

I’m building a league system and currently it stores and updates the players ‘elo

  • 0

I’m building a league system and currently it stores and updates the players ‘elo score’ depending on the result. Now, I’m trying to add in ‘HighCharts’ to display the players elo score over the season in a sweet looking line chart. Someone suggested I use Papertrail to store the updates and I have got that all installed.

Now here comes my problem, I can’t seem to figure out how to spit out the users elo_score versions in an array easy for ‘HighCharts’ to use. I can get the last updates to elo_score:

Last updated score = <%= @player.versions.last.reify.elo_score %> 

But I can’t seem to find the syntax to spit out all the ‘versions’ for ‘elo_score’. Something like “1000, 1020, 1043, 1020”.

I’ve also tried:

<%= @player.versions.map { |version| version.reify.elo_score} %>

But this gives me “undefined method `elo_score’ for nil:NilClass”. While just <%= @player.versions.map { |version| version.reify %> spits out all information in the record and obviously not just the elo_score.

Can anyone help? Sorry if I’ve not made this clear, I’m absolute brand new to rails, and this is just a fun project in my spare time but I’m having a blast!

Thanks alot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:23:25+00:00Added an answer on June 4, 2026 at 4:23 am

    What you did here:

    @player.versions.map { |version| version.reify.elo_score }
    

    Is perfectly fine to take all those scores and put them in an array. The problem that you’re getting (the nil:NilClass stuff) is coming because at least one reify is nil. That is, that some version doesn’t have a reify.

    If each version is supposed to have a reify, be sure to add that as a model validation, and find in your code where the reify is being set and see why it’s nil.

    If it’s okay for a version to have a nil reify, you could accomplish it a number of ways, but the straightforward and explicit way would look like this:

    elo_scores = []
    @player.versions.each do |version|
        unless version.reify.nil?
            elo_scores << version.reify.elo_score
        end
    end
    

    I would suggest putting this in to a method, like get_elo_scores, and then you could more easily call it like:

    @player.get_elo_scores
    

    EDIT For clarification from the comments:

    Your User model (or Player model, whatever you named it) should have a method that looks like this:

    def get_elo_scores
        elo_scores = []
        self.versions.each do |version|
            unless version.reify.nil?
                elo_scores << version.reify.elo_score
            end
        end
        return elo_scores
    end
    

    I apologize for not making this clearer, but you won’t have access to @player within this method because that only exists in the context of your controller and view. The above is now a proper instance method: it will call .versions upon itself, and the rest is fine. I also added an explicit return call at the end.

    Now you will be able to call @player.get_elo_scores on any User (or Player) object.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.