0

I'm trying to upgrade an app from rails 2.3 to 3.0 and it has a file

app/utility/interface/import/import_statistics_manager.rb

which contains

class Utility::Interface::Import::ImportStatisticsManager         
//code here  
end

I beleive Utility::Interface::Import are the folder names in its file path but used as namespaces

This code works fine in rails 2.3 but when I try to run with rails 3.0.6 it throws a NameError

Error message:
   uninitialized constant Utility
Exception class:
   NameError

FYI: rails 2.3 uses ruby 1.8.7 and rails 3.0.6 uses ruby 1.9.2

Please correct me if my understandings are not correct

Siva
  • 7,780
  • 6
  • 47
  • 54
  • Have you added the directories to your autoload path in application.rb? – dhoelzgen Apr 25 '13 at 07:05
  • 1
    I would try to add the one you mentioned in your post, too - Not all directories in the app folder are autoloaded automatically. – dhoelzgen Apr 25 '13 at 07:20
  • @dhoelzgen yes it has "config.autoload_paths += %W(#{config.root}/app/utility)" – Siva Apr 25 '13 at 07:22
  • @dhoelzgen please feel free to edit the post – Siva Apr 25 '13 at 07:24
  • Ok, then try to nest the modules explicitly, as shown in [this post](http://stackoverflow.com/questions/14348891/rails-3-trouble-with-namespaces-custom-classes-uninitialized-constant). If this doesn't help, please provide some more info on where the error occurs. – dhoelzgen Apr 25 '13 at 07:28
  • @dhoelzgen thanx man!! that post helped adding "app" folder to autoload instead of "app//utility/interface/import" fixed it. – Siva Apr 25 '13 at 07:43

1 Answers1

1

For future reference (see comments on the question):

It helped adding the complete app folder to the autoload paths.

See this post for further info.

Community
  • 1
  • 1
dhoelzgen
  • 1,150
  • 7
  • 15