简体   繁体   English

尝试在Heroku上进行部署,无法正常工作,现在本地服务器无法正常工作

[英]Tried deploying on Heroku, didn't work and now local server not working

UPDATE - SOLVED: Both my local server and heroku wouldn't work. 更新-解决:我的本地服务器和heroku都无法工作。 Two main components fixed this problem. 两个主要组件解决了此问题。

Thank you everyone for your help and support! 谢谢大家的帮助和支持! Knowing that there are people out there willing to help is invaluable in this learning process; 在学习过程中,知道有人愿意提供帮助是非常宝贵的; hence, my effort to document this error/solution for future coders to bang their heads a little less. 因此,我努力记录此错误/解决方案,以使将来的编码人员花更少的力气。

:( My app was working locally and then I followed the directions to push onto Heroku. :(我的应用程序在本地运行,然后按照说明推送到Heroku。

I got Heroku's super descriptive and comforting error message: "We're sorry, but something went wrong." 我收到了Heroku的超级描述和令人安慰的错误消息:“很抱歉,出了点问题。”

In other words, now my app doesn't work locally or on heroku... would love to solve this with your help. 换句话说,现在我的应用程序无法在本地或在Heroku上运行...希望在您的帮助下解决此问题。 Thank you. 谢谢。

So I tried some things (in this order): 所以我尝试了一些事情(按此顺序):

  • I took out gem 'sqlite3' and replaced it with gem 'pg' 我取出gem 'sqlite3'并替换为gem 'pg'
  • In my gemfile, included ruby '2.0.0' 在我的gemfile中,包括ruby'2.0.0 ruby '2.0.0'
  • heroku rake db:migrate heroku耙db:migrate

I tried solving the local problem first. 我首先尝试解决本地问题。

When I tried rails server (to test locally), I got the following error: 当我尝试使用Rails服务器(在本地测试)时,出现以下错误:

Somehow when deploying to Heroku, there was inconsistency with my Ruby version, using 2.0.0 and gemfile was expected 1.8. 在以某种方式部署到Heroku时,我的Ruby版本与2.0.0不一致,gemfile预期为1.8。

   ms.rb:777:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1056:in `gem'
        from /usr/bin/rails:18
    Davids-MacBook-Air-6:portfolio davidngo$ rails server
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
        from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1056:in `gem'
        from /usr/bin/rails:18

What solved it for me: 是什么解决了我的问题:

  • reinstalled my ruby 2.0.0 by running rvm reinstall ruby 2.0.0 通过运行rvm reinstall ruby 2.0.0安装我的rvm reinstall ruby 2.0.0
  • run bundle install #=> when I saw "Your Ruby version is 2.0.0, but your Gemfile specified 1.8" I knew that I was in the right direction because this error is super common/all over StackOverFlow 当我看到“您的Ruby版本为2.0.0,但您的Gemfile指定为1.8”时,请运行bundle install #=>,我知道我的方向正确,因为此错误非常普遍/遍及整个StackOverFlow

The Main Heroku Problem: Heroku主要问题:

State changed from starting to complete
2013-08-20T03:29:43.118968+00:00 heroku[run.2135]: Error R99 (Platform error) -> Failed to launch the dyno within 10 seconds
2013-08-20T03:29:43.119187+00:00 heroku[run.2135]: Stopping process with SIGKILL
2013-08-20T03:31:00.784270+00:00 heroku[router]: at=info method=GET path=/ host=shrouded-citadel-6554.herokuapp.com fwd="107.193.213.240" dyno=web.1 connect=2ms service=24ms status=500 bytes=643
2013-08-20T03:31:00.800238+00:00 app[web.1]: 
2013-08-20T03:31:00.800238+00:00 app[web.1]: Started GET "/" for 107.193.213.240 at 2013-08-20 03:31:00 +0000
2013-08-20T03:31:00.800238+00:00 app[web.1]: 
2013-08-20T03:31:00.802209+00:00 app[web.1]: Processing by CollectionsController#index as HTML
2013-08-20T03:31:00.808688+00:00 app[web.1]: Completed 500 Internal Server Error in 6ms
2013-08-20T03:31:00.810234+00:00 app[web.1]: 
2013-08-20T03:31:00.810234+00:00 app[web.1]:              WHERE a.attrelid = '"collections"'::regclass
2013-08-20T03:31:00.810234+00:00 app[web.1]:                                         ^
2013-08-20T03:31:00.810234+00:00 app[web.1]: LINE 4:              WHERE a.attrelid = '"collections"'::regclass
2013-08-20T03:31:00.810234+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
2013-08-20T03:31:00.810234+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-08-20T03:31:00.810234+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "collections" does not exist
2013-08-20T03:31:00.810234+00:00 app[web.1]:              ORDER BY a.attnum
2013-08-20T03:31:00.810234+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-08-20T03:31:00.810234+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-08-20T03:31:00.810392+00:00 app[web.1]: ):
2013-08-20T03:31:00.810392+00:00 app[web.1]:   app/controllers/collections_controller.rb:4:in `index'
2013-08-20T03:31:00.810392+00:00 app[web.1]: 
2013-08-20T03:31:00.810392+00:00 app[web.1]: 
2013-08-20T03:31:01.224316+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=shrouded-citadel-6554.herokuapp.com fwd="107.193.213.240" dyno=web.1 connect=3ms service=8ms status=200 bytes=0

What solved it for me: 是什么解决了我的问题:

heroku pg:reset DATABASE --confirm YOUR_APP_NAME
heroku run rake db:setup
heroku restart
heroku open

Related & Important Files: 相关和重要文件:

In database.yml: development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 在database.yml中:开发:适配器:sqlite3数据库:db / development.sqlite3池:5超时:5000

test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  encoding: utf8
  database: portfolio_production
  pool: 5
  username:
  password:

In Gemfile: 在Gemfile中:

source 'https://rubygems.org'

ruby '2.0.0'

gem 'rails', '3.2.3'

group :development, :test do
    gem 'sqlite3'
end

group :production do
    gem 'pg'
end

It looks like as Heroku did'nt run db:migrate on deployment. 似乎Heroku在部署时未运行db:migrate。

Try to run 尝试跑步

 #heroku run rake db:migrate

on console after deploying it again. 在控制台上再次部署它之后。

After running a migration you'll want to restart your app with 运行迁移后,您将需要重新启动应用

#heroku restart 

to reload the schema and pickup any schema changes. 重新加载架构并拾取任何架构更改。

You still can use sqlite for development your Gemfile should look like this: 您仍然可以使用sqlite进行开发,您的Gemfile应该如下所示:

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

This will let you to use postgresql on Heroku(production mode) and sqlite locally. 这将允许您在Heroku(生产模式)和sqlite本地使用postgresql Don't forget to run your database migration as soon as you will deploy on heroku. 不要忘记在heroku上部署后立即运行数据库迁移。 You can run migrations with heroku run rake db:migrate command. 您可以使用heroku run rake db:migrate命令heroku run rake db:migrate

You will need to change your database.yml file to reflect new adapter . 您将需要更改您的database.yml文件以反映新的adapter Also you should have postgres setup locally. 另外,您应该在本地安装postgres。

New database.yml file should look like - 新的database.yml文件应如下所示-

development:
  adapter: postgresql
  encoding: utf8
  database: app_name_development
  pool: 5
  username:
  password:

test:
  adapter: postgresql
  encoding: utf8
  database: app_name_test
  pool: 5
  username:
  password:

production:
  adapter: postgresql
  encoding: utf8
  database: app_name_production
  pool: 5
  username:
  password:

After you have modified the database.yml run 修改database.yml运行

rake db:drop db:create db:migrate

To create fresh database in Postgres. 在Postgres中创建新的数据库。

You can have a different adapter locally than in production, that is no problem. 您可以在本地使用与生产环境不同的适配器,这没问题。 When deploying to Heroku, you need to run your migrations by hand, it's not part of the deploy process. 部署到Heroku时,您需要手动运行迁移,这不是部署过程的一部分。

So, you first deploy it regularly and then you run heroku run rake --trace db:migrate . 因此,您首先要定期部署它,然后运行heroku run rake --trace db:migrate The error that you are seeing tells you that the table for Collection model doest not exist. 您所看到的错误告诉您Collection模型的表不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 heroku rake db:迁移不起作用 - heroku rake db:migrate didn't work Javascript在Heroku中不起作用,但在本地环境中不起作用 - Javascript Doesn't Work in Heroku but in Local Environment 修复后仍无法部署到Heroku - Deploying to Heroku still doesn't work after fixing Rails应用程序可在本地服务器上运行,但最重要的页面在Heroku上无法运行 - Rails app works on local server but the most important page won't work on Heroku sample_app的“帐户”按钮在heroku上不起作用,但在本地服务器上起作用 - Account button for sample_app doesn't work on heroku, but works on local server Heroku证书-不包含CA捆绑包,现在无法更新(Pem不能为空,无效,到期时不能为空) - Heroku certs — Didn't include CA bundle and now cannot update (Pem can't be blank, is invalid, expires at can't be blank) Rails + Heroku:应用程序在Heroku上崩溃但在本地服务器上运行 - Rails + Heroku: App crashing on Heroku but working on local server RoR2.8和Heroku:我安装了一个插件,可以在本地工作,现在heroku根本无法工作 - RoR2.8 & Heroku: I installed a plugin, works locally, now heroku doesn't work at all Ruby on Rails:Ran rake资产:预编译,现在本地部署和heroku部署都不包含引导程序 - Ruby on Rails: Ran rake assets:precompile and now both local and heroku deployment don't include bootstrap 每当我提出请求时,Rails都会向我显示此消息,我尝试在根目录中放置2个png图像,但没有用 - Rails is showing me this message every time that I do a request, I tried putting 2 png images in the root directory but It didn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM