【问题标题】:Deployed Rails 4.2.4 on heroku but can't run app在 heroku 上部署 Rails 4.2.4 但无法运行应用程序
【发布时间】:2015-11-21 16:00:14
【问题描述】:

我创建了一个 Rails 4.2.4 应用程序并将其部署到 Heroku,而无需添加任何代码。它在 localhost 上运行良好,但在 Heroku 上运行良好。以下是 Heroku 日志:

at=info method=GET path="/" host=bagala.herokuapp.com request_id=b838aff9-e39b-4e32-8407-8d3e10da8117 fwd="178.91.253.104" dyno=web.1 connect=0ms service=3ms status=404 bytes=228

请注意,有时我会收到状态 404。这很奇怪。不知道发生了什么?

这是我的 gemfile:

source 'https://rubygems.org'

ruby '2.2.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use postgresql as the database for Active Record
gem 'pg'
# 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'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem '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

# 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

【问题讨论】:

  • 错误状态为404,所以你的资源可能是not_found,你可以再检查一遍,如果还是不行,请输入更多日志/描述
  • 不确定这是否能解决您当前的问题,但您需要将其添加到您的 gemfile:gem 'rails_12factor', group: :productiondevcenter.heroku.com/articles/…
  • 如果你发布你的 routes.rb 我想我可以给你一个答案,可能是没有根集。

标签: ruby-on-rails heroku


【解决方案1】:

当然,您会收到错误 404,因为这是一个全新的 Rails 应用程序,您没有向其中添加任何路由。在开发环境中,Rails 会显示一个欢迎页面,但在production 环境中,它将是一个 404 页面,因为应用程序实际上没有任何页面可以显示给用户。

【讨论】:

    猜你喜欢
    • 2016-06-23
    • 2023-03-27
    • 2020-02-20
    • 2022-07-15
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 2020-04-07
    • 1970-01-01
    相关资源
    最近更新 更多