I run a web hosting service and have lots of server troubleshooting experience. 502 is a nginx thing, though it could be something in the ruby app's config, but it should not be in the code itself.
I don't have specific ruby experience, but I should not need to mess with anything but the config files and ruby.
Assuming that he error is persistent, not sporadic and if you don't find yourself a server/ruby guy, I'll get this figured out, even if it takes some extra time, which is why I bid low.