简体   繁体   English

Rails新的默认应用程序无法在Heroku服务器上运行

[英]Rails new default app is not working on heroku server

I have created a new app with command rails new publication 我用命令栏创建了一个新应用程序

I have run it on local machine(Windows 7 machine) with rails s command. 我已经使用rails s命令在本地计算机(Windows 7计算机)上运行了它。 It works fine and shows the rails default page. 它工作正常,并显示rails默认页面。

when I pushed it to heroku server by command git push heroku master it is uploaded successfully but does not work . 当我通过命令git push heroku master将其推送到heroku服务器时,它已成功上传,但无法正常工作。 Its shows error 显示错误

https://quiet-spire-3568.herokuapp.com/ https://quiet-spire-3568.herokuapp.com/

here is my heroku logs 这是我的heroku日志

 Rockman@ROCKMAN-PC /c/Sites/publication (master) $ heroku logs Your version of git is 1.9.4.. Which has serious security vulnerabilities. More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x ←[36m2015-04-11T04:11:31.675313+00:00 app[web.1]:←[0m bin/rails:4:in `<main>' ←[36m2015-04-11T04:11:31.675320+00:00 app[web.1]:←[0m [2015-04-11 04:11:31] INFO going to shutdown ... ←[36m2015-04-11T04:11:31.675323+00:00 app[web.1]:←[0m Exiting ←[36m2015-04-11T04:11:31.893442+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 37363 -e production` ←[36m2015-04-11T04:11:32.788181+00:00 heroku[web.1]:←[0m Process exited with status 143 ←[36m2015-04-11T04:11:35.834860+00:00 app[web.1]:←[0m [2015-04-11 04:11:35] INFO WEBrick 1.3.1 ←[36m2015-04-11T04:11:35.835340+00:00 app[web.1]:←[0m [2015-04-11 04:11:35] INFO WEBrick::HTTPServer#start: pid=3 port=37363 ←[36m2015-04-11T04:11:35.834888+00:00 app[web.1]:←[0m [2015-04-11 04:11:35] INFO ruby 2.0.0 (2015-02-25) [x86_64-linux] ←[36m2015-04-11T04:11:36.299932+00:00 heroku[web.1]:←[0m State changed from starting to up ←[33m2015-04-11T04:11:45.483107+00:00 heroku[router]:←[0m at=info method=GET path="/" host=quiet-spire-3568.herokuapp.com request_id=33964df 4-4d3a-4271-bb3f-52c12102e812 fwd="103.230.106.8" dyno=web.1 connect=1ms service=88ms status=404 bytes=1829 ←[36m2015-04-11T04:11:45.401590+00:00 app[web.1]:←[0m => Rails 4.2.1 application starting in production on http://0.0.0.0:37363 ←[36m2015-04-11T04:11:45.401583+00:00 app[web.1]:←[0m => Booting WEBrick ←[36m2015-04-11T04:11:45.401592+00:00 app[web.1]:←[0m => Run `rails server -h` for more startup options ←[36m2015-04-11T04:11:45.401594+00:00 app[web.1]:←[0m => Ctrl-C to shutdown server ←[36m2015-04-11T04:11:45.401596+00:00 app[web.1]:←[0m Started GET "/" for 103.230.106.8 at 2015-04-11 04:11:45 +0000 ←[36m2015-04-11T04:11:45.479861+00:00 app[web.1]:←[0m ←[36m2015-04-11T04:11:45.479869+00:00 app[web.1]:←[0m ActionController::RoutingError (No route matches [GET] "/"): ←[36m2015-04-11T04:11:45.479871+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/debug_ exceptions.rb:21:in `call' ←[36m2015-04-11T04:11:45.479873+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/show_e xceptions.rb:30:in `call' ←[36m2015-04-11T04:11:45.479875+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:38:in `call_ap p' ←[36m2015-04-11T04:11:45.479877+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `block i n call' ←[36m2015-04-11T04:11:45.479878+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging. rb:68:in `block in tagged' ←[36m2015-04-11T04:11:45.479880+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging. rb:26:in `tagged' ←[36m2015-04-11T04:11:45.479883+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `call' ←[36m2015-04-11T04:11:45.479882+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging. rb:68:in `tagged' ←[36m2015-04-11T04:11:45.479885+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/reques t_id.rb:21:in `call' ←[36m2015-04-11T04:11:45.479886+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/methodoverride.rb:22:in `call' ←[36m2015-04-11T04:11:45.479888+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/runtime.rb:18:in `call' ←[36m2015-04-11T04:11:45.479890+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/cache/strategy/ local_cache_middleware.rb:28:in `call' ←[36m2015-04-11T04:11:45.479891+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/static .rb:113:in `call' ←[36m2015-04-11T04:11:45.479893+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/sendfile.rb:113:in `call' ←[36m2015-04-11T04:11:45.479894+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:518:in `call' ←[36m2015-04-11T04:11:45.479896+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:164:in `call' ←[36m2015-04-11T04:11:45.479897+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/lock.rb:17:in `call' ←[36m2015-04-11T04:11:45.479899+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/content_length.rb:15:in `call' ←[36m2015-04-11T04:11:45.479900+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service' ←[36m2015-04-11T04:11:45.479901+00:00 app[web.1]:←[0m vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' ←[36m2015-04-11T04:11:45.479903+00:00 app[web.1]:←[0m vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' ←[36m2015-04-11T04:11:45.479904+00:00 app[web.1]:←[0m vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' ←[36m2015-04-11T04:11:45.479906+00:00 app[web.1]:←[0m ←[36m2015-04-11T04:11:45.479907+00:00 app[web.1]:←[0m ←[32m2015-04-11T04:21:24.153651+00:00 heroku[api]:←[0m Deploy 68bcbac by jaforrockman695@gmail.com ←[32m2015-04-11T04:21:24.153651+00:00 heroku[api]:←[0m Release v8 created by jaforrockman695@gmail.com ←[36m2015-04-11T04:21:24.310724+00:00 heroku[web.1]:←[0m State changed from up to starting ←[36m2015-04-11T04:21:27.005169+00:00 heroku[web.1]:←[0m Starting process with command `bin/rails server -p 52295 -e production` ←[36m2015-04-11T04:21:27.731941+00:00 heroku[web.1]:←[0m Stopping all processes with SIGTERM ←[36m2015-04-11T04:21:28.568788+00:00 app[web.1]:←[0m /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select' ←[36m2015-04-11T04:21:28.568781+00:00 app[web.1]:←[0m [2015-04-11 04:21:28] FATAL SignalException: SIGTERM ←[36m2015-04-11T04:21:28.568790+00:00 app[web.1]:←[0m /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in start' ←[36m2015-04-11T04:21:28.568792+00:00 app[web.1]:←[0m /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start' ←[36m2015-04-11T04:21:28.568794+00:00 app[web.1]:←[0m /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start' ←[36m2015-04-11T04:21:28.568795+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:35:in `run ' ←[36m2015-04-11T04:21:28.568797+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/server.rb:286:in `start' ←[36m2015-04-11T04:21:28.568799+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/server.rb:80:in `start' ←[36m2015-04-11T04:21:28.568802+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks. rb:75:in `tap' ←[36m2015-04-11T04:21:28.568801+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks. rb:80:in `block in server' ←[36m2015-04-11T04:21:28.568805+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks. rb:39:in `run_command!' ←[36m2015-04-11T04:21:28.568807+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>' ←[36m2015-04-11T04:21:28.568808+00:00 app[web.1]:←[0m bin/rails:4:in `require' ←[36m2015-04-11T04:21:28.568810+00:00 app[web.1]:←[0m bin/rails:4:in `<main>' ←[36m2015-04-11T04:21:28.568804+00:00 app[web.1]:←[0m /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks. rb:75:in `server' ←[36m2015-04-11T04:21:28.568818+00:00 app[web.1]:←[0m [2015-04-11 04:21:28] INFO going to shutdown ... ←[36m2015-04-11T04:21:28.568890+00:00 app[web.1]:←[0m Exiting ←[36m2015-04-11T04:21:28.568821+00:00 app[web.1]:←[0m [2015-04-11 04:21:28] INFO WEBrick::HTTPServer#start done. ←[36m2015-04-11T04:21:29.588949+00:00 heroku[web.1]:←[0m Process exited with status 143 ←[36m2015-04-11T04:21:30.425566+00:00 app[web.1]:←[0m [2015-04-11 04:21:30] INFO WEBrick 1.3.1 ←[36m2015-04-11T04:21:30.425592+00:00 app[web.1]:←[0m [2015-04-11 04:21:30] INFO ruby 2.0.0 (2015-02-25) [x86_64-linux] ←[36m2015-04-11T04:21:30.426106+00:00 app[web.1]:←[0m [2015-04-11 04:21:30] INFO WEBrick::HTTPServer#start: pid=3 port=52295 ←[36m2015-04-11T04:21:31.018560+00:00 heroku[web.1]:←[0m State changed from starting to up ←[33m2015-04-11T04:21:37.891471+00:00 heroku[router]:←[0m at=info method=GET path="/" host=quiet-spire-3568.herokuapp.com request_id=065981b 6-5f85-48c4-ac54-cd6ecd99a450 fwd="103.230.106.8" dyno=web.1 connect=1ms service=63ms status=404 bytes=1829 ←[36m2015-04-11T04:21:37.834914+00:00 app[web.1]:←[0m => Booting WEBrick ←[36m2015-04-11T04:21:37.834921+00:00 app[web.1]:←[0m => Rails 4.2.1 application starting in production on http://0.0.0.0:52295 ←[36m2015-04-11T04:21:37.834923+00:00 app[web.1]:←[0m => Run `rails server -h` for more startup options ←[36m2015-04-11T04:21:37.834925+00:00 app[web.1]:←[0m => Ctrl-C to shutdown server ←[36m2015-04-11T04:21:37.834927+00:00 app[web.1]:←[0m Started GET "/" for 103.230.106.8 at 2015-04-11 04:21:37 +0000 ←[36m2015-04-11T04:21:37.886595+00:00 app[web.1]:←[0m ←[36m2015-04-11T04:21:37.886602+00:00 app[web.1]:←[0m ActionController::RoutingError (No route matches [GET] "/"): ←[36m2015-04-11T04:21:37.886605+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/debug_ exceptions.rb:21:in `call' ←[36m2015-04-11T04:21:37.886606+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/show_e xceptions.rb:30:in `call' ←[36m2015-04-11T04:21:37.886608+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:38:in `call_ap p' ←[36m2015-04-11T04:21:37.886610+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `block i n call' ←[36m2015-04-11T04:21:37.886615+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging. rb:26:in `tagged' ←[36m2015-04-11T04:21:37.886613+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging. rb:68:in `block in tagged' ←[36m2015-04-11T04:21:37.886616+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging. rb:68:in `tagged' ←[36m2015-04-11T04:21:37.886618+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `call' ←[36m2015-04-11T04:21:37.886619+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/reques t_id.rb:21:in `call' ←[36m2015-04-11T04:21:37.886621+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/methodoverride.rb:22:in `call' ←[36m2015-04-11T04:21:37.886623+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/runtime.rb:18:in `call' ←[36m2015-04-11T04:21:37.886625+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/cache/strategy/ local_cache_middleware.rb:28:in `call' ←[36m2015-04-11T04:21:37.886628+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/sendfile.rb:113:in `call' ←[36m2015-04-11T04:21:37.886626+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/static .rb:113:in `call' ←[36m2015-04-11T04:21:37.886629+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:518:in `call' ←[36m2015-04-11T04:21:37.886631+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:164:in `call' ←[36m2015-04-11T04:21:37.886632+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/lock.rb:17:in `call' ←[36m2015-04-11T04:21:37.886633+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/content_length.rb:15:in `call' ←[36m2015-04-11T04:21:37.886638+00:00 app[web.1]:←[0m vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' ←[36m2015-04-11T04:21:37.886635+00:00 app[web.1]:←[0m vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service' ←[36m2015-04-11T04:21:37.886636+00:00 app[web.1]:←[0m vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' ←[36m2015-04-11T04:21:37.886639+00:00 app[web.1]:←[0m vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' ←[36m2015-04-11T04:21:37.886640+00:00 app[web.1]:←[0m ←[36m2015-04-11T04:21:37.886642+00:00 app[web.1]:←[0m 

And her is my gemfile 她是我的宝石

 source 'https://rubygems.org' gem 'rails', '4.2.1' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc group :development, :test do gem 'sqlite3' gem 'byebug' gem 'web-console', '~> 2.0' end group :production do gem 'pg' gem 'rails_12factor' end gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] ruby "2.0.0" 

I have changed config\\environment\\production.rb 我已经更改了config \\ environment \\ production.rb

config.assets.compile = false to config.assets.compile = true config.assets.compile = false到config.assets.compile = true

Please help me 请帮我

The default "welcome" page is only served up in development, so it's normal to get a 404 in production. 默认的“欢迎”页面仅在开发中提供,因此在生产环境中获取404是正常的。

That page is provided by a controller and templates that are part of the rails gem and as you can see here the routes to it are only added in development. 该页面由控制器和模板提供,这些控制器和模板是rails gem的一部分,并且您可以在此处看到的路由仅在开发中添加。

please set your root in routes with something like: 请通过以下方式设置您的根目录:

root to: 'pages#main' 

where page is controller name and main is the method 其中page是控制器名称,main是方法

You need to manually configure your home page in production since the default one only applies to development mode. 您需要在生产环境中手动配置主页,因为默认页面仅适用于开发模式。

To paraphrase the documentation, do something like this: 要解释文档,请执行以下操作:

rails generate controller Greetings

Then go to app/controllers/greetings_controller.rb and modify slightly: 然后转到app/controllers/greetings_controller.rb并稍作修改:

class GreetingsController < ApplicationController
  def index
    @message = "Hello, how are you today?"
  end
end

Then go to app/views/greetings/index.html.erb and do this: 然后转到app/views/greetings/index.html.erb并执行以下操作:

<h1>A Greeting for You!</h1>
<p><%= @message %></p>

Finally in config/routes.rb : 最后在config/routes.rb

root :to => 'greetings#index'

Incidentally, this will also let you hit /greetings too. 顺便说一句,这也使您也可以打/greetings

In your config/application.rb, try adding this to the last line (before the "end"s... 在您的config / application.rb中,尝试将其添加到最后一行(在“结束”之前...

config.assets.initialize_on_precompile = false

If you're pushing to Heroku with Git, you'll want to re-commit with this line. 如果您要使用Git推送至Heroku,则需要重新提交此行。 Otherwise start a new Heroku app with this line included. 否则,请使用此行启动一个新的Heroku应用程序。 Idk about any other changes you've made in trying to solve this, but when I used to use Heroku, this line was necessary for it to work. IDK约你在试图解决这个问题作出任何其他更改,但是当我用的Heroku,这条线是必要为它工作。 Good luck! 祝好运!

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

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