0

First time deploying on heroku and my app, which is working fine locally on heroku (logs) throws NoMethodError (undefined method `round' for nil:NilClass) for this line of code:

def show
  if @movie.reviews.blank?
    @average_review = 0
  else
    @average_review = @movie.reviews.average(:rating).round(2)
  end
end

I checked the data with console and it has a movie, review and rating. I'd provide more code but I'm a beginner and have no idea where to check. Appreciate any help, thanks!

nusound
  • 35
  • 4
  • 1
    You can open heroku console with `heroku run console` , you are getting this error because one of your @movie.reviews don't have rating value . so it is null. and round method not used with nil value – Vishal Nov 11 '17 at 09:35
  • try to adding value in that review else handle that error. – Vishal Nov 11 '17 at 09:37
  • @Vishal Yes, that was it thanks! I missed it because I did click on rating but I guess I have a problem with jquery.raty star rating. I thought it just doesn't show the stars but it's obviously not working at all. – nusound Nov 11 '17 at 10:01
  • Is your issue resolved ? – Vishal Nov 11 '17 at 10:40
  • @Vishal Yes, [here](https://stackoverflow.com/questions/35168574/why-is-my-raty-stars-not-working-loading-appearing-in-heroku-although-it-works-p)'s the answer. Again, thanks for your help, it redirected me to where the problem really was. – nusound Nov 11 '17 at 11:07
  • yes, my pleasure. – Vishal Nov 11 '17 at 11:10

0 Answers0