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
en
It appears that your class User has not be instantiated, which seems unusual, unless you have 'user.rb' in a location other than 'models'. It is often the case that classes aren't loaded in development unless they are specifically in that directory, but one solution I use is this line that you could put just within your code that you expect to be called prior to the offending line you have..
Rails.application.eager_load! if Rails.env == "development"
The conditional part is probably unnecessary, but I include it just to be certain its effect only occurs in development.