postgresql 您要找的页面不存在 - heroku+rails

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20705434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:14:22  来源:igfitidea点击:

The page you were looking for doesn't exist - heroku+rails

ruby-on-railsrubypostgresqlherokusqlite

提问by Ridje

Good day. I am trying to deploy rails-application on heroku according to Hartl's book Ruby on Rails tutorial. I did $ git push heroku masterand it was done correctly. But when i use $ heroku openthere is a text

再会。我正在尝试根据 Hartl 的书 Ruby on Rails 教程在 heroku 上部署 rails-application。我做到了$ git push heroku master,而且做得对。但是当我使用时$ heroku open有一个文本

`The page you were looking for doesn't exist.

`您要查找的页面不存在。

You may have mistyped the address or the page may have moved. When I start rails locally with $ rails sthere are no mistakes and 127.0.0.1:3000 works nicely. But if I use $ rails s -e productionthere is a similar mistake

您可能输入了错误的地址或页面可能已移动。当我在本地启动 rails 时$ rails s没有错误并且 127.0.0.1:3000 运行良好。但如果我使用$ rails s -e production有类似的错误

The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.

您要找的页面不存在。您可能输入了错误的地址或页面可能已移动。

Btw, according to similar's issues I tried to change

顺便说一句,根据类似的问题,我试图改变

config.assets.compile = true

config.assets.compile = true

My Gemfile.lock:

我的 Gemfile.lock:

  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.2)
      actionpack (= 4.0.2)
      mail (~> 2.5.4)
    actionpack (4.0.2)
      activesupport (= 4.0.2)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.2)
      activesupport (= 4.0.2)
      builder (~> 3.1.0)
    activerecord (4.0.2)
      activemodel (= 4.0.2)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.2)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.2)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    addressable (2.3.5)
    arel (4.0.1)
    atomic (1.1.14)
    builder (3.1.4)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    erubis (2.7.0)
    excon (0.25.3)
    execjs (2.0.2)
    heroku (3.2.1)
      heroku-api (~> 0.3.7)
      launchy (>= 0.3.2)
      netrc (~> 0.7.7)
      rest-client (~> 1.6.1)
      rubyzip
    heroku-api (0.3.15)
      excon (~> 0.25.1)
    hike (1.2.3)
    i18n (0.6.9)
    jbuilder (1.5.3)
      activesupport (>= 3.0.0)
      multi_json (>= 1.2.0)
    jquery-rails (3.0.4)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.1)
    launchy (2.4.2)
      addressable (~> 2.3)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.25.1)
    minitest (4.7.5)
    multi_json (1.8.2)
    netrc (0.7.7)
    pg (0.17.1-x86-mingw32)
    polyglot (0.3.3)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.2)
      actionmailer (= 4.0.2)
      actionpack (= 4.0.2)
      activerecord (= 4.0.2)
      activesupport (= 4.0.2)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.2)
      sprockets-rails (~> 2.0.0)
    railties (4.0.2)
      actionpack (= 4.0.2)
      activesupport (= 4.0.2)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.1.1)
    rdoc (3.12.2)
      json (~> 1.4)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rubyzip (1.1.0)
    sass (3.2.13)
    sass-rails (4.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0)
    sdoc (0.3.20)
      json (>= 1.1.3)
      rdoc (~> 3.10)
    sprockets (2.10.1)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    sqlite3 (1.3.8-x64-mingw32)
    sqlite3 (1.3.8-x86-mingw32)
    sqlite3-ruby (1.3.3)
      sqlite3 (>= 1.3.3)
    thor (0.18.1)
    thread_safe (0.1.3)
      atomic
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (2.1.0)
      coffee-rails
    tzinfo (0.3.38)
    uglifier (2.4.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)

PLATFORMS
  x64-mingw32
  x86-mingw32

DEPENDENCIES
  coffee-rails (~> 4.0.0)
  heroku
  jbuilder (~> 1.2)
  jquery-rails
  pg
  rails (= 4.0.2)
  sass-rails (~> 4.0.0)
  sdoc
  sqlite3 (= 1.3.8)
  sqlite3-ruby
  turbolinks
  uglifier (>= 1.3.0)

My Gemfile

我的 Gemfile

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use sqlite3 as the database for Active Record
group :development, :test do 
  gem 'sqlite3-ruby', :require => 'sqlite3'
  gem 'sqlite3', '1.3.8'
end

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

gem 'heroku'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/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', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

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

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

# Use debugger
# gem 'debugger', group: [:development, :test]

group :production do
  gem 'pg'
end

routes.rb:

路线.rb:

FirstApp::Application.routes.draw do
  many comments 
end

It's just created project with rails new. There is the same message if I try to get another pages.

它只是用rails new. 如果我尝试获取其他页面,则会出现相同的消息。

回答by marknach

I just ran into some similar issues a few weeks ago - it could be many things but here are some things that I forgot when doing this for the first time

几周前我刚刚遇到了一些类似的问题 - 可能有很多事情,但这里有一些我第一次这样做时忘记的事情

Migrate your prod db heroku run rake db:migrate

迁移您的产品数据库 heroku run rake db:migrate

make sure heroku has your precompiled assets - rake assets:precompileand push again to heroku

确保 heroku 具有您的预编译资产 -rake assets:precompile并再次推送到 heroku

Also, check this section, Hartl mentions that you need a rootroute defined in order for the default rails page to work on heroku.

另外,请检查本节,Hartl 提到您需要root定义一个路由,以便默认 rails 页面在 heroku 上工作。