Accessing models from within the lib directory in a Rails 3 project
===

I have a file in the lib directory that uses some constants defined in a model, like:

    class User < ActiveRecord::Base
       MAX_EMAIL_ADDRESS_LENGTH = 255
    end

and then I have in lib/foo.rb

    module Foo
      LONG_EMAIL_ADDRESS = "foo@bar.com".rjust(User::MAX_EMAIL_ADDRESS_LENGTH, "a")
    end

It fails due to not finding the class User. How can I load User before that file on lib?