Uninitialized constant

hi i am developing my first app with ror and i have experience and
problem which i could not solve so far … i need a hand please :wink:

following scenario…

  • i have a file config/project.rb (my application specifc
    configurations) with a module “Project” which holds a constant
    EMAIL_PATTERN (with a regex pattern for email validation)
  • i load this file in the environment.rb with require_dependency
    “project”
  • i have a user model which includes
    validates_format_of :email, :with => PROJECT::EMAIL_PATTERN

the problem now:
i have a view for the user which is fine on the first load … but when i
submit the form within the view (postback) then i got the error

uninitialized constant User::Project

i dont understand this because i have several unit test which test the
functionality of validating and there the pattern is applied fine. it
has only a problem after postback…
any ideas?

I’m not sure why you decided to use require_dependency you might be
better off using

require File.join(File.dirname(FILE), ‘project’)

Also:

validates_format_of :email, :with => PROJECT::EMAIL_PATTERN

should be:

validates_format_of :email, :with => Project::EMAIL_PATTERN to match
the case of the module name.

HTH,
Nicholas

On Nov 18, 5:11 am, Michal G. <rails-mailing-l…@andreas-

thanks nicholas… the problem was the require_dependency … when i use
the common require then it works fine … i used require_dependency
because i want the files be reloaded everytime i change something … i
dont understand why it does not work with it.

btw: the upper cased project was a typo her in the post