I am using RubyMine to create a website. I have a calculation I’m doing
in the model that is no longer working. It has worked previously, but
now I’m receiving a NoMethodError stating that there is an undefined
method `+’ for nil:NilClass
I have multiple integers I’m adding in my “roster.rb
” model, with the
scope sorting as follows:
scope :sorted, -> { select('*, (passing_yards + passing_tds +
qb_rushing + coaching_staff + age + physical_tools + intellect +
surrounding_talent + health + consistency) as xoi’).order(‘xoi DESC’) }
def xoi
passing_yards + passing_tds + qb_rushing + coaching_staff + age
- physical_tools + intellect + surrounding_talent + health + consistency
end
I have database entries using these integers that have worked just days
ago, with the calculation working properly, and the numbers sorting
accurately.
I can still define “xoi” with just one of these integers and the integer
will show up properly. I can also define “xoi” with 2 + 2 and the answer
will show up on my webpage properly as 4. But this calculation is no
longer working.
The html page displaying the results of this calculation is as follows:
<% @players.each do |player| %>
<tr>
<td><%= player.xoi %></td>
<td><%= player.last_name %></td>
<td><%= player.first_name %></td>
<td><%= player.pos %></td>
<td><%= player.team %></td>
<td><%= player.passing_yards %></td>
<td><%= player.passing_tds %></td>
<td><%= player.qb_rushing %></td>
<td><%= player.coaching_staff %></td>
<td><%= player.age %></td>
<td><%= player.physical_tools %></td>
<td><%= player.intellect %></td>
<td><%= player.surrounding_talent %></td>
<td><%= player.health %></td>
<td><%= player.consistency %></td>
I must have made some small tweak that I can’t recover from. Version
Control did not work for me.
It’s as though the “+” is just no longer working for this calculation
(but I’m sure I’m just doing something wrong).
I’d appreciate any insight.