If you are using Devise there should already be a method for this defined.  If not it would probably make sense to define this on the Application controller.