This project is archived and is in readonly mode.
uninitialized constant Rails::DeprecatedConstant::Rails (NameError)
-
Bharat Ruparel
Please ignore if you think this is not important.
Here is what happened. My Rails 3 app in Release Candidate 1 with ruby 1.9.2-head from a month ago was working fine with the following initializer in config/initializers directory:
Dir.glob( "#{ RAILS_ROOT }/lib/*.rb" ).each { |f| require f }
After upgrading to Rails 3 Release candidate 2 with stable release of Ruby 1.9.2-p0, it won't start as I reported above. I changed the initializer code to read
Dir.glob( "#{ Rails.root }/lib/*.rb" ).each { |f| require f }
and it started fine and the tests pass.
I think we need to publish a warning that the "old" style constants will cause Release candidate 2 to not start?
Bharat
-
Rohit Arondekar
- State changed from new to needs-more-info
- Importance changed from to Low
Can you try using
Dir.glob( "#{ RAILS_ROOT }/lib/*.rb" ).each { |f| require f }in a fresh RC 2 app? It didn't give any errors for me. I'm guessing this is an aws-s3-0.6.2 issue. But just to be sure can you check?
-
Bharat Ruparel
Hello Rohit,
The error is gone after I made the afore mentioned change. Rails 3 reandomly picks on aws-s3 or right_aws and reports the
uninitialized constant Rails::DeprecatedConstant::Rails (NameError)
error. I have googled around to find if there are any reported incidences of Rails 3 not playing well with these two gems but it is possible that I may have missed relevant information.
How do you suggest that I check aws?
Thanks.
Bharat -
Deleted User
I can confirm this error. Its actually two things having to do with RAILS_ROOT. From deprecation.rb line 48:
DeprecatedConstant.deprecate("RAILS_ROOT", "Rails.root.to_s")First problem is when the proc on line 21 is called, it ends up as Rails::DeprecatedConstant::Rails which does not exist. So first change is:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root.to_s")Same would apply to the other deprecated constants.
Next the call to RAILS_ROOT call .to_path (at least from attachment fu, see attachment_fu.rb, line 4):
@@tempfile_path = File.join(RAILS_ROOT, 'tmp', 'attachment_fu')Calling to_path on a string blows up. So these changes fix the problem for me:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root") DeprecatedConstant.deprecate("RAILS_ENV", "::Rails.env") DeprecatedConstant.deprecate("RAILS_DEFAULT_LOGGER", "::Rails.logger") -
Bharat Ruparel
If you folks need to look at a real app. I just uploaded both Rails 2.3.8 and Rails 3.0RC2 versions of my app on Github.
http://github.com/bruparel/file_manager238
http://github.com/bruparel/file_manager3
Bharat
-
Neeraj Singh
- State changed from needs-more-info to resolved
@cfis The changes suggested by you are already there.
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root.to_s") DeprecatedConstant.deprecate("RAILS_ENV", "::Rails.env") DeprecatedConstant.deprecate("RAILS_DEFAULT_LOGGER", "::Rails.logger") -
Deleted User
Neeraj - I see that the :: as been added, so that is good.
But I was also saying this:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root.to_s")
Should be this:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root")
Notice the removal of "to_s"