I have a rails 3.2.20 app with the following structure (shortened for readability)
.
├── assets
├── controllers
├── counting
│ ├── data_function.rb
├── datatables
├── helpers
├── mailers
├── models
│ ├── data_function.rb
├── validators
└── views
You can see data_function.rb file inside both counting and models folders. The code is as follows.
models/data_function.rb
# encoding: utf-8
class DataFunction < ActiveRecord::Base
...
end
counting/data_function.rb
module Counting
class DataFunction
...
end
end
Problem is, I get this error when I load my rails app:
/Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/dependencies.rb:503:in `load_missing_constant': Expected /Users/rafa/projects/proj/app/counting/data_function.rb to define DataFunction (LoadError)
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/dependencies.rb:192:in `block in const_missing'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/dependencies.rb:190:in `each'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/dependencies.rb:190:in `const_missing'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/inflector/methods.rb:230:in `block in constantize'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/inflector/methods.rb:229:in `each'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/inflector/methods.rb:229:in `constantize'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.20/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activemodel-3.2.20/lib/active_model/observing.rb:189:in `block in observe'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activemodel-3.2.20/lib/active_model/observing.rb:189:in `collect!'
from /Users/rafa/.rvm/gems/ruby-2.1.5/gems/activemodel-3.2.20/lib/active_model/observing.rb:189:in `observe'
from /Users/rafa/projects/proj/app/models/audit_observer.rb:3:in `<class:AuditObserver>'
from /Users/rafa/projects/proj/app/models/audit_observer.rb:2:in `<top (required)>'
inside the audit_observer.rb there is a observer set for the DataFunction model, I guess this is causing the problem, but shouldn't the namespacing resolve this clashing issue? What am I doing wrong here?
Aucun commentaire:
Enregistrer un commentaire