Error Deploying images on Heroku with Rails?
Hey, I encountered a problem when I was deploying my first project on Heroku that I was having a hard time debugging. I created a full CRUD, MVC project using Ruby on Rails, running everything locally.
localhost:3000 was running beautifully without any bugs, and I was excited to finally see my first project deployed live so that my friends and family could finally see what I was working on.
But when I deployed the project, I kept getting a rendering error. My first app’s screen would look like the following:
Now I have to check my Heroku logs to try and debug this problem. Looking in the log file, says a
status=206 . When you look this error up, your find the following:
“The HTTP 206 Partial Content success status response code indicates that the request has succeeded and has the body contains the requested ranges of data, as described in the Range header of the request.”
Whats going on? I double check everything on the localhost and it is working fine. I try to debug by taking out the backup image I had to render incase my background video failed to play. With that code commented out, pushed up to Github and Heroku it loaded! Success!!
But why was this happening? Why did it run locally but not on Heroku? Why did my other picture render onto the screen, but my background image failed to compile and crash all of my code?
The difference between the two images are the image types. The image that rendered onto the screen is
jpg while the image that caused problems loading is a
jpeg . I didn’t know they would be problems when trying put this site live online, but it seems to be the difference.
The takeaway from this story is to always use
jpg image types when working with rails and Heroku. I am sure there are multiple solutions for this problem, but being that this is the first time I am hosting something live, I am happy to provide a simple solution to the problem.
Please feel free to checkout my first website deployed and let me know what your thoughts on it are.