【问题标题】:Having trouble finding a solution for Rails/Heroku: "The page you were looking for doesn't exist"无法找到 Rails/Heroku 的解决方案:“您要查找的页面不存在”
【发布时间】:2014-07-06 00:45:14
【问题描述】:

我不久前注册了一个月 Rails 计划,现在才开始着手。我已经安装了 Rails,设置了 GitHub 和 Heroku。一切似乎都运行良好,Rails 测试应用程序在我的本地服务器上运行,我在推送到 Heroku 时没有收到任何错误,但我不断收到“您要查找的页面不存在”。

我尝试添加根路由、安装“pg”gem、运行 rake db:migrate 等。此时我决定删除整个 Ruby 项目,重新开始并重新安装“pg”gem .

我的 Gemfile 如下所示: 源'https://rubygems.org'

gem 'rails', '4.1.4'

group :production do
    gem 'pg'
end

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



gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

gem 'spring',        group: :development

我的 Heroku 日志如下所示:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Using json 1.8.1
       Using minitest 5.3.5
       Using thread_safe 0.3.4
       Using builder 3.2.2
       Using i18n 0.6.9
       Using erubis 2.7.0
       Using rake 10.3.2
       Using rack 1.5.2
       Using mime-types 1.25.1
       Using polyglot 0.3.5
       Using arel 5.0.1.20140414130214
       Using coffee-script-source 1.7.0
       Using execjs 2.2.1
       Using thor 0.19.1
       Using hike 1.2.3
       Using pg 0.17.1
       Using multi_json 1.10.1
       Using bundler 1.6.3
       Using tilt 1.4.1
       Using sass 3.2.19
       Using rdoc 4.1.1
       Using tzinfo 1.2.1
       Using treetop 1.4.15
       Using rack-test 0.6.2
       Using coffee-script 2.2.0
       Using uglifier 2.5.1
       Using sdoc 0.4.0
       Using activesupport 4.1.4
       Using mail 2.5.4
       Using actionview 4.1.4
       Using activemodel 4.1.4
       Using jbuilder 2.1.1
       Using actionpack 4.1.4
       Using railties 4.1.4
       Using actionmailer 4.1.4
       Using activerecord 4.1.4
       Using sprockets 2.11.0
       Using coffee-rails 4.0.1
       Using jquery-rails 3.1.1
       Using sprockets-rails 2.1.3
       Using turbolinks 2.2.2
       Using rails 4.1.4
       Using sass-rails 4.0.3
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (0.61s)
       Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       Asset precompilation completed (2.01s)
       Cleaning assets
       Running: rake assets:clean
-----> WARNINGS:
       Include 'rails_12factor' gem to enable all platform features
       See https://devcenter.heroku.com/articles/rails-integration-gems for more information.

       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.0.0'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information.

       No Procfile detected, using the default web server (webrick)
       https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for Ruby  -> console, rake, web, worker

-----> Compressing... done, 21.2MB
-----> Launching... done, v7
       http://immense-lake-7186.herokuapp.com/ deployed to Heroku

任何帮助将不胜感激!谢谢!

【问题讨论】:

标签: ruby-on-rails ruby heroku


【解决方案1】:

错误

首先,The Page You Were Looking For Doesn't Exist 的 Rails 错误是 Rails 错误,而不是 Heroku 错误:

不同之处在于如果你有一个“Heroku”错误,它是平台级别的;这意味着它会在您遇到后端系统(数据库、依赖项、操作系统等)问题时显示:

--

由于您收到第一个 (red) 错误,因此您需要查看导致此错误的原因。

如果在您第一次点击应用程序时发生这种情况,则可能意味着您没有声明 root 路径您没有定义任何 controller#actions 来处理请求。

我会试试这个:

#config/routes.rb
root to: "application#index"

#app/controllers/application_controller.rb
Class ApplicationController < ActionController::Base
    def index
    end
end

#app/views/application/index.html.erb
Test

当您再次推送到Heroku 时,您应该尝试:

$ git add .
$ git commit -a -m "Heroku"
$ git push heroku master

【讨论】:

    猜你喜欢
    • 2014-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-25
    相关资源
    最近更新 更多