Heroku:你正在寻找的页面不存在没有路由匹配[GET]“/” [英] Heroku:The page you were looking for doesn't exist No route matches [GET] "/"

查看:346
本文介绍了Heroku:你正在寻找的页面不存在没有路由匹配[GET]“/”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在Heroku上,使用 git push heroku master 推送我的文件后访问应用程序URL会给我错误:



您正在查找的网页不存在。您可能错误地址或页面可能已移动。

p $ p> 2014-05-17T12:31:00.796904 + 00:00 app [web.1]:[2014-05-17 12:31:00]信息WEBrick :: HTTPServer#开始完成。
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 :在`开始'
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:`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:在< top(必填) >'
2014-05-17T12:31:00.796840 + 00:00 app [web.1]:[2014-05-17 12:31:00]致命SignalException:SIGTERM
2014-05 -17T12:31:00.796868 + 00:00 app [web.1]:bin / rails:4:'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:在`run'
2014-05- 17T12:31:00.796869 + 00:00 app [web.1]:bin / rails:4:in` lt; 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将关闭...
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:在`start'
2014-05-17T12:31:00.796944 + 00:00 app [web.1] :正在退出
2014-05-17T12:31:00.796860 + 00:00应用[web.1]:/app/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails / commands / com
mands_tasks.rb:81:在`block in server'
2014-05-17T12:31:00.138102 + 00:00 heroku [web.1]:停止所有使用SIGTERM的进程
2014-05-17T12:31:02.926026 + 00:00 heroku [web.1]:进程已退出,状态为143

这是我的Gemfile:

 #Bundle edge Rails改为:gem'rails',github:'rails / rails'
gem'rails','4.1.1'
#使用sqlite3作为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'

#在样式表中使用SCSS
gem'sass-rails','〜> 4.0.3'
#使用Uglifier作为JavaScript资源的压缩器
gem'uglifier','> = 1.3.0'
#使用CoffeeScript for .js.coffee资产和视图
gem'咖啡栏','〜> 4.0.0'
#请参阅https://github.com/sstephenson/execjs#readme以获得更多支持的运行时
#gem'therubyracer',平台:: ruby​​

#使用jquery作为JavaScript库
gem'jquery-rails'
#Turbolinks使Web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem'turbolinks'
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder','〜> 2.0'
#bundle exec rake doc:rails在doc / api下生成API。
gem'sdoc','〜> 0.4.0',组::doc

#使用ActiveModel has_secure_password
#gem'bcrypt','〜> 3.1.7'

#使用独角兽作为应用服务器
#gem'unicorn'

#使用Capistrano进行部署
#gem'capistrano- rails',group::development

#使用调试器
#gem'debugger',group:[:development,:test]

#Windows不包括zoneinfo文件,因此捆绑tzinfo-data gem
gem'tzinfo-data',平台:[:mingw,:mswin]

我还修改了我的 production.rb 加入:

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

Heroku也要求这是false
config.assets .initialize_on_precompile = false

以下是我的routes.rb:

  Rails.application.routes.draw do 
出口

这个文件中的大部分代码都会被注释掉。

请帮忙吗?

解决方案

E dit



也是。所以在查看你所拥有的文件之后,我看不到任何页面可以查看这意味着heroku没有任何显示。首先,我想推荐Micheal Hartl的Ruby on Rails教程。你可以通过googlingruby on rails tutorial hartl免费找到它,这将更好地解释Ruby在rails上的表现,如果你通过它并觉得它有帮助,我相信你可以捐赠一些钱来使用它,我会建议,因为这是一个了不起的资源,我和其他许多人已经习惯在rails上学习ruby。



好的首先为什么你的代码不工作。您在routes.rb中拥有root'welcome#index'。但是没有welcome_controller.rb和'index'操作。从命令行类型创建它(在这里重要的是大大小写)

  rails生成控制器欢迎索引


$ b这会创建一个索引页面(你在路径文件中的那个页面),它为它创建视图和'welcome'控制器自动。你可以调用任何你想要的页面,但是这对你在routes.rb中已经有的代码有效。在学习本教程时,您会更加了解这一点。这也会创建很多文件,这个教程也会帮助你理解所有这些。我只是试图解决你在这里发布的问题,并尽可能保持主题,同时让你的方向正确。

再次推动git,然后推向heroku。当你再次打开heroku时,它应该着陆在该页面上,除了一般消息之外,页面上不会有任何内容,我认为你应该看到在app / views / welcome / index.rb中查找我的内容。如果你看到你的路由工作正常。


I'm new to Rails. This question has been asked a lot but unfortunately none of the solutions provided have worked for me.

On Heroku, visiting the app URL after pushing my files with git push heroku master gives me the error:

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

Here's my log:

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

Here's my 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]

I've also modified my production.rb by addding:

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

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

and here's my routes.rb:

Rails.application.routes.draw do
exit

most of the code in this file is commented.

Please help?

解决方案

Edit

O.k. so after looking at the files you have, I do not see any pages to view which means heroku has nothing to display. First off I want to recommend the ruby on rails tutorial by Micheal Hartl. You can find it free by googling "ruby on rails tutorial hartl", this will explain Ruby on rails better than I ever could, if you work through it and feel like it helped I believe you can donate some money for using it and I would recommend that because it is an amazing resource that I, and probably many others, have used to learn ruby on rails.

O.k. first why your code is not working. You have root 'welcome#index' in routes.rb. But there is no welcome_controller.rb with an 'index' action. To create that from command line type (capitaliazation is important here)

 rails generate controller Welcome index

This will create an index page (the one you have in your routes file), it creates the view and the 'welcome' controller for it automatically. You can call the page anything you want but this will work for the code you already have in routes.rb. You will understand this more when you work through the tutorial. This will also create a lot of files, again the tutorial will help you understand what all that is. I am only trying to solve the issue you posted about right here and stay on topic as best I can while getting you going in the right direction.

After that you will have to push to git again and then push to heroku. When you open heroku again it should land on that page, there will not be anything on the page other than a generic message, I think you should see something along the lines of "find me in app/views/welcome/index.rb" If you see that your routing is working.

这篇关于Heroku:你正在寻找的页面不存在没有路由匹配[GET]“/”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆