简体   繁体   中英

Heroku not running migrations due to ruby module

I am unable to run migrations in Heroku, which I believe is due to a module I created in my lib directory. After executing the command heroku run rake db:migrate I receive the below error:

uninitialized constant ApplicationController::PgTools /app/app/controllers/application_controller.rb:4:in <class:ApplicationController>

Line 4 of the Application controller is include PgTools , which is there to gain access to methods within the PgTools module I created.

Despite the heroku migration failing, I am able to run rake db:migrate in my local dev environments without fail (please note that both environments utilize postgres databases).

I also have the following two lines in my application.rb file

config.autoload_paths += %W(#{config.root}/lib)

config.autoload_paths += Dir["#{config.root}/lib/**/"]

I resolved the error by renaming Pg_Tools.rb to pgtools.rb and modifying all include PgTools statements to include Pgtools

Links that I used in the troubleshooting process are shown below

Rails 3 library not loading until require

http://www.williambharding.com/blog/technology/rails-3-autoload-modules-and-classes-in-production/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM