ruby on rails - Heroku - Uninitialized constant for importing a module -


i have module

lib/basicstats.rb   (module basicstats ...etc. end) 

i importing model

class vote < activerecord::base     include basicstats     #additional class code etc. end 

i grep-d module , 'basicstats' referenced in basicstats.rb , app/model/vote.rb.

this works fine local development. during heroku deployment getting error , can't seem recognize module? (i'm curious how working in local development without require anywhere.)

2015-03-28t22:19:52.714077+00:00 app[web.1]: /app/app/models/vote.rb:16:in `<class:vote>': uninitialized constant basicstats (nameerror) 

it sounds module isn't being explicitly required or auto-loaded rails (this will/won't happen depending version of rails you're using , how config.autoload_paths configured).

your best bet add initializer explicitly requires module:

# config/initializers/basicstats.rb  require rails.root.join('lib/basicstats') 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -