尝试将Rails应用程序推送到Heroku时加载错误

时间:2017-11-01 08:51:33

标签: ruby-on-rails postgresql heroku production

我有一个Rails应用程序我一直在努力推向Heroku。但是,每当我运行git push heroku master时,我都会收到以下错误:

 To https://git.heroku.com/top5application.git
  ! [remote rejected] master -> master (pre-receive hook declined

我查看了堆栈跟踪,它表明:

 remote:        LoadError: cannot load such file -- List

由于List是应用程序中的模型,我检查了该文件并将其中的require“List”命令显示为灰色,但这没有任何区别。

我真的很感激任何人对此有任何见解,因为我到处搜索,找不到可行的解决方案。

编辑:堆栈跟踪是:

remote: -----> Installing node-v6.11.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        LoadError: cannot load such file -- List
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `block in require'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/app/models/user.rb:3:in `<class:User>'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/app/models/user.rb:1:in `<top (required)>'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `block in require'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/railties-5.0.6/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote:        /tmp/build_095d59bef53353aa48e41eb90360323e/vendor/bundle/ruby/2.3.0/gems/rake-12.2.1/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to top5application.
remote: 
To https://git.heroku.com/top5application.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/top5application.git'

2 个答案:

答案 0 :(得分:0)

从模型require 'List'List中删除User

不需要在模型中加载模型,因为app目录中的所有文件都将由Rails自动加载。

答案 1 :(得分:0)

我明白了。我只是在删除了需要'List'到heroku而不是master之后做出的更改。您必须先将更改提交到master,然后将它们推送到Heroku。