Heroku:您正在寻找的页面不存在没有路由匹配[GET]" /"

时间:2014-05-17 12:22:10

标签: ruby-on-rails git heroku

我是Rails的新手。这个问题已经被问了很多,但不幸的是,所提供的解决方案都没有对我有用。

在Heroku上,在使用git push heroku master推送文件后访问应用网址时出现错误:

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

这是我的日志:

2014-05-17T12:31:00.796904+00:00 app[web.1]: [2014-05-17 12:31:00] INFO  WEBrick::HTTPServer#start done.
2014-05-17T12:31:00.796853+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2014-05-17T12:31:00.796864+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands/com
mands_tasks.rb:40:in `run_command!'
2014-05-17T12:31:00.796850+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in
 start'
2014-05-17T12:31:00.796866+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands.rb:
17:in `<top (required)>'
2014-05-17T12:31:00.796840+00:00 app[web.1]: [2014-05-17 12:31:00] FATAL SignalException: SIGTERM
2014-05-17T12:31:00.796868+00:00 app[web.1]:    bin/rails:4:in `require'
2014-05-17T12:31:00.796855+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.r
b:14:in `run'
2014-05-17T12:31:00.796869+00:00 app[web.1]:    bin/rails:4:in `<main>'
2014-05-17T12:31:00.796856+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:264:in
`start'
2014-05-17T12:31:00.796876+00:00 app[web.1]: [2014-05-17 12:31:00] INFO  going to shutdown ...
2014-05-17T12:31:00.796858+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands/ser
ver.rb:69:in `start'
2014-05-17T12:31:00.796944+00:00 app[web.1]: Exiting
2014-05-17T12:31:00.796860+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/commands/com
mands_tasks.rb:81:in `block in server'
2014-05-17T12:31:00.138102+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2014-05-17T12:31:02.926026+00:00 heroku[web.1]: Process exited with status 143

这是我的Gemfile:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'
gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# 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', '~> 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

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

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

我还通过添加修改了我的production.rb

  #config/environments/production.rb
  config.assets.compile = true

  # Heroku also requires this to be false
  config.assets.initialize_on_precompile=false

这是我的routes.rb:

Rails.application.routes.draw do
exit

此文件中的大部分代码都已注释。

请帮帮忙?

1 个答案:

答案 0 :(得分:1)

修改

O.k。所以看完你的文件后,我看不到任何要查看的页面,这意味着heroku无法显示。首先,我想推荐Micheal Hartl的ruby on rails教程。你可以通过googling&#34; ruby​​ on rails tutorial hartl&#34;免费找到它,这将比我更好地解释Ruby on rails,如果你通过它并觉得它有帮助我相信你可以捐出一些钱使用它,我会建议,因为它是一个惊人的资源,我,可能还有许多其他人,曾经习惯在铁轨上学习红宝石。

O.k。首先为什么你的代码不起作用。你有root&#39; welcome #index&#39;在routes.rb中。但是没有带有&#39;索引的welcome_controller.rb&#39;行动。从命令行类型创建它(资本化在这里很重要)

 rails generate controller Welcome index

这将创建一个索引页面(您在路径文件中拥有的索引页面),它会创建视图和欢迎&#39;控制器自动。您可以随意调用页面,但这将适用于routes.rb中已有的代码。在学习本教程时,您将更加了解这一点。这也将创建大量文件,教程将再次帮助您了解所有文件。我只是试图解决你在这里发布的问题,并尽可能地保持主题,同时让你朝着正确的方向前进。

之后你将不得不再次推送git然后推送到heroku。当你再次打开heroku时它应该落在那个页面上,除了一般信息之外,页面上没有任何东西,我认为你应该看到&#34;在app / views / welcome / index中找到我的内容.RB&#34;如果您发现您的路由工作正常。