Mongrel changes its user and group id to the user you specify when started as another user (say, root).
However, it does not change the environment variables from the user it was started as. In particular, ENV["USER"] and ENV["HOME"] remain set to, say, ‘root’ and ‘/root’ respectively.
If you then try to use the ruby gpgme wrappers you’ll run into strange errors. No Ruby exceptions are triggered, but things go wrong in the gpgme_n C wrapper code. From there, gpg is called as the mongrel user, but with environment variables pointing to root’s home directory. Ouch.
Of course you won’t see the problem in development mode (because typically there you run mongrel as the user you are working as).
The solution is simple: force those two variables in your environment.rb file to the correct values for the user you are running as, but not for development mode.