0
votes
  • App in Rails 4.0.12 / Ruby 2.0.0p481

  • runs without problems on production and on one dev notebook

  • completely isolated with rbenv / bundle / svn

  • trying to get it up in another dev pc and I hit when starting server with

bundle exec rails s

LoadError - Unable to autoload constant Venta, expected /home/sistemas/Projects/microgestion/trunk/app/models/concerns/modelos_impresion/venta.rb to define it:

activesupport (4.0.13) lib/active_support/dependencies.rb:464:in load_missing_constant' activesupport (4.0.13) lib/active_support/dependencies.rb:184:inconst_missing' activesupport (4.0.13) lib/active_support/dependencies.rb:495:in load_missing_constant' activesupport (4.0.13) lib/active_support/dependencies.rb:184:in `const_missing'

Now /home/sistemas/Projects/microgestion/trunk/app/models/concerns/modelos_impresion/venta.rb has this defined:

module Concerns::ModelosImpresion::Venta

but the correct class Venta is defined at:

/home/sistemas/Projects/microgestion/trunk/app/model/ventas/venta.rb:

class Venta < ActiveRecord::Base
...
end

In config/application.rb I have:

# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += Dir["#{config.root}/app/models/**/", "#{config.root}/app/services/**/", "#{config.root}/lib/**/"]

I know the two files have the same name, but I looked like because they were on different hierarchies it didn't matter..

Now the million dollar question is, why if in two environments is resolving correctly the dependency to the correct file but not in this particular PC with everything isolated correctly?

There is some non-deterministic behaviour in the way Rails resolves the 'missing constant' dependencies to files?

1

1 Answers

0
votes

I had a similar problem, and I resolved it by replacing gems with an older version. The project was using a prior version of gems, and I had updated it using bundle update. This caused only some gems to be updated to the latest version, and that caused the above issue for ROM gems. When I reverted back to the old version of gems, it fixed the problem.