Revised, using .present? test instead of Rails.env

This also works, thanks for the tip. Devise works with this patch.