I get a strange error. My application works fine on my localhost, but on my Heroku server it gives this error: TypeError (String can't be coerced into Fixnum):
Here is my code:
@rep = rep_score(@u)
According to the magazines, that line throws an error. I commented on this and pushed the changes in Heroku, and the application now works fine.
Here is the rep_score
method:
def rep_score(user) rep = 0 user.badges.each do |b| rep = rep + b.rep_bonus end return rep end
Also rep_bonus
is an integer in the database.
Again this works fine on the local host. Let me know what you think.
After removing return
from the rep_score
method rep_score
it works fine. I'm still new to Ruby, is there something wrong with putting return
? This is a habit from other languages.
source share