Heroku上的Rails应用程序不会显示“欢迎登机”页面

时间:2017-03-13 18:11:08

标签: ruby-on-rails ruby-on-rails-4 heroku

我已经创建了一个新的Rails应用程序。当我使用rails server命令在本地运行Rails应用程序时,将显示默认的“欢迎登机”页面。我已将此部署到Heroku,但是当我尝试访问Heroku应用程序时,收到The page you were looking for doesn't exist.消息。

为什么我没有收到默认的“欢迎登机”页面?

Heroku日志:

2017-03-13T19:40:33.717559+00:00 heroku[router]: at=info method=GET path="/" host=XXXXX.herokuapp.com request_id=58aa5f0e-c83b-411b-a27c-484325f2eaf0 fwd="90.208.48.181" dyno=web.1 connect=1ms service=6ms status=404 bytes=1829 protocol=https

2017-03-13T19:40:33.715776+00:00 app[web.1]: Started GET "/" for 90.208.48.181 at 2017-03-13 19:40:33 +0000

2017-03-13T19:40:33.717555+00:00 app[web.1]: 

2017-03-13T19:40:33.717557+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"):

2017-03-13T19:40:33.717559+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'

2017-03-13T19:40:33.717560+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'

2017-03-13T19:40:33.717561+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:38:in `call_app'

2017-03-13T19:40:33.717561+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:20:in `block in call'

2017-03-13T19:40:33.717562+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/tagged_logging.rb:68:in `block in tagged'

2017-03-13T19:40:33.717562+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/tagged_logging.rb:26:in `tagged'

2017-03-13T19:40:33.717563+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/tagged_logging.rb:68:in `tagged'

2017-03-13T19:40:33.717563+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:20:in `call'

2017-03-13T19:40:33.717564+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/request_id.rb:21:in `call'

2017-03-13T19:40:33.717564+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'

2017-03-13T19:40:33.717565+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'

2017-03-13T19:40:33.717566+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'

2017-03-13T19:40:33.717566+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/static.rb:116:in `call'

2017-03-13T19:40:33.717567+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'

2017-03-13T19:40:33.717567+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/engine.rb:518:in `call'

2017-03-13T19:40:33.717567+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:165:in `call'

2017-03-13T19:40:33.717568+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'

2017-03-13T19:40:33.717568+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'

2017-03-13T19:40:33.717568+00:00 app[web.1]:   vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'

2017-03-13T19:40:33.717569+00:00 app[web.1]:   vendor/ruby-2.2.6/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'

2017-03-13T19:40:33.717569+00:00 app[web.1]:   vendor/ruby-2.2.6/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'

2017-03-13T19:40:33.717570+00:00 app[web.1]:   vendor/ruby-2.2.6/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

2017-03-13T19:40:33.717570+00:00 app[web.1]: 

2017-03-13T19:40:33.717570+00:00 app[web.1]: 

的Gemfile:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# bootstrap
gem 'bootstrap-sass',       '3.2.0.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails',         '4.0.3'
gem 'jquery-ui-rails', '~> 4.2.1'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
gem 'jquery-turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'rails_12factor'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

2 个答案:

答案 0 :(得分:1)

欢迎页面是公共文件夹中的默认index.html文件。

如果routes.rb文件中未指定root,则显示默认的index.html页面。

它在ngnix / apache服务上运行良好,但可能无法在heroku上运行。

如果你想显示一个页面然后创建一个控制器,例如HomeController并在views / home下添加文件index.html,并在route.rb中添加以下代码

public void test(int i=0,string s="")
    {
      // Function Body
    }

答案 1 :(得分:0)

我认为类似的事情发生在我身上,你必须检查你的routes.rb文件,检查你是否有根路线,如:

# File: config/routes.rb
root "controller#action" #something like:  root "clients#index"
相关问题