简体   繁体   English

找不到Heroku Rails页面

[英]Heroku Rails Page Not Found

I'm trying to deploy a sample rails app on heroku. 我正在尝试在heroku上部署示例Rails应用程序。 After creating a very basic app, adding a git repository, committing everything and "heroku create", I push it up to heroku. 在创建了非常基本的应用程序,添加了git存储库,提交所有内容并“ heroku创建”之后,我将其推到了heroku。 No errors at all in terminal, but when I open the browser with the correct address, I get the following: 终端完全没有错误,但是当我使用正确的地址打开浏览器时,会得到以下信息:

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

I've searched for three hours and used the heroku tutorial on how to deploy the app but I just can't figure out what I'm doing wrong. 我已经搜索了三个小时,并使用了heroku教程来了解如何部署该应用程序,但是我无法弄清楚自己在做什么错。 Here is my Gemfile: 这是我的Gemfile:

source 'https://rubygems.org'

ruby '2.0.0'

gem 'rails', '4.0.0.beta1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'json'

group :production do
  gem 'pg'
  gem 'rails', '4.0.0.beta1'
  gem 'railties', '4.0.0.beta1'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  #gem 'sass-rails',   '~> 3.2.3'
  gem 'sass-rails',   '~> 4.0.0.beta1'
  #gem 'coffee-rails', '~> 3.2.1'
  gem 'coffee-rails', '~> 4.0.0.beta1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

I've repeated the steps above several times, didn't work. 我已经重复了上述步骤几次,但是没有用。 Thanks! 谢谢!

Edit: added heroku console logs: 编辑:添加了heroku控制台日志:

2013-04-13T14:15:14.800540+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands/server.rb:80:in `start'
2013-04-13T14:15:14.801066+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands.rb:73:in `<top (required)>'
2013-04-13T14:15:14.801066+00:00 app[web.1]:    script/rails:6:in `<main>'
2013-04-13T14:15:14.801375+00:00 app[web.1]: [2013-04-13 14:15:14] INFO  going to shutdown ...
2013-04-13T14:15:14.801542+00:00 app[web.1]: [2013-04-13 14:15:14] INFO  WEBrick::HTTPServer#start done.
2013-04-13T14:15:14.801066+00:00 app[web.1]:    script/rails:6:in `require'
2013-04-13T14:15:14.800540+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands.rb:73:in `tap'
2013-04-13T14:15:14.822878+00:00 app[web.1]: => Booting WEBrick
2013-04-13T14:15:14.822878+00:00 app[web.1]: => Rails 4.0.0.beta1 application starting in production on http://0.0.0.0:44478
2013-04-13T14:15:14.822878+00:00 app[web.1]: => Call with -d to detach
2013-04-13T14:15:14.822878+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-04-13T14:15:14.822878+00:00 app[web.1]: 
2013-04-13T14:15:14.822878+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"):
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `block in call'
2013-04-13T14:15:14.822878+00:00 app[web.1]: Started GET "/" for 178.25.122.239 at 2013-04-13 14:02:08 +0000
2013-04-13T14:15:14.822878+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:38:in `call_app'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `call'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `tagged'
2013-04-13T14:15:14.822878+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:25:in `tagged'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:510:in `call'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:96:in `call'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
2013-04-13T14:15:14.822878+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `block in tagged'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2013-04-13T14:15:14.823204+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2013-04-13T14:15:14.823433+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
2013-04-13T14:15:14.823433+00:00 app[web.1]: 
2013-04-13T14:15:14.823433+00:00 app[web.1]: Started GET "/" for 178.25.122.239 at 2013-04-13 14:04:08 +0000
2013-04-13T14:15:14.823433+00:00 app[web.1]: 
2013-04-13T14:15:14.823657+00:00 app[web.1]: 
2013-04-13T14:15:14.823657+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"):
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:38:in `call_app'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `block in call'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `block in tagged'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:25:in `tagged'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `tagged'
2013-04-13T14:15:14.823657+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:510:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:96:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
2013-04-13T14:15:14.823871+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
2013-04-13T14:15:14.824082+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
2013-04-13T14:15:14.824082+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2013-04-13T14:15:14.824082+00:00 app[web.1]: 
2013-04-13T14:15:14.824082+00:00 app[web.1]: 
2013-04-13T14:15:14.824082+00:00 app[web.1]: Started GET "/favicon.ico" for 178.25.122.239 at 2013-04-13 14:04:09 +0000
2013-04-13T14:15:14.824082+00:00 app[web.1]: 
2013-04-13T14:15:14.824082+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
2013-04-13T14:15:14.824082+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2013-04-13T14:15:14.824082+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2013-04-13T14:15:14.824082+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:38:in `call_app'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `block in call'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `block in tagged'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:67:in `tagged'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/rack/logger.rb:21:in `call'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/tagged_logging.rb:25:in `tagged'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bu
ndle/ruby/2.0.0/gems/actionpack-4.0.0.beta1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2013-04-13T14:15:14.824292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:510:in `call'
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2013-04-13T14:15:14.824503+00:00 app[web.1]: 
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
2013-04-13T14:15:14.824503+00:00 app[web.1]: Exiting
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:96:in `call'
2013-04-13T14:15:14.824503+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
2013-04-13T14:15:14.824503+00:00 app[web.1]: 
2013-04-13T14:15:14.516222+00:00 heroku[web.1]: State changed from starting to up
2013-04-13T14:15:16.056837+00:00 heroku[web.1]: Process exited with status 143
2013-04-13T14:16:05.609544+00:00 app[web.1]: 
2013-04-13T14:16:05.609544+00:00 app[web.1]: To disable this message remove the `whitelist_attributes` option from your
2013-04-13T14:16:05.609544+00:00 app[web.1]: DEPRECATION WARNING: Model based mass assignment security has been extracted
2013-04-13T14:16:05.609544+00:00 app[web.1]: out of Rails into a gem. Please use the new recommended protection model for
2013-04-13T14:16:05.609544+00:00 app[web.1]: params or add `protected_attributes` to your Gemfile to use the old one.
2013-04-13T14:16:05.609544+00:00 app[web.1]: `config/application.rb` file and any `mass_assignment_sanitizer` options
2013-04-13T14:16:05.609544+00:00 app[web.1]: See http://guides.rubyonrails.org/security.html#mass-assignment for more information.
2013-04-13T14:16:05.609544+00:00 app[web.1]:  
2013-04-13T14:16:05.609544+00:00 app[web.1]: 
2013-04-13T14:16:05.609544+00:00 app[web.1]: from your `config/environments/*.rb` files.
2013-04-13T14:16:05.730223+00:00 heroku[router]: at=info method=GET path=/ host=mighty-depths-7233.herokuapp.com fwd="178.25.122.239" dyno=web.1 connect=1ms service=209ms status=404 bytes=728
2013-04-13T14:16:05.980431+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=mighty-depths-7233.herokuapp.com fwd="178.25.122.239" dyno=web.1 connect=0ms service=6ms status=404 bytes=728

First of all there's a good guide on routing in Rails here . 首先,这里有关于Rails路由的良好指南。

Lets say you have an Article model in your app and an articles controller, you have to define the routes for this resource under config/routes.rb. 假设您的应用程序中有一个Article模型,一个articles控制器,则必须在config / routes.rb下为此资源定义路由。 Rails allows you to add routes for index, show new, create, edit, update and destroy in one line: Rails允许您为index, show new, create, edit, update添加路线,在一行中index, show new, create, edit, update路线index, show new, create, edit, updatedestroy

resources :articles

This will map to the following: 这将映射到以下内容:

GET     /articles           index   display a list of all articles
GET     /articles/new       new     return an HTML form for creating a new article
POST    /articles           create  create a new article
GET     /articles/:id       show    display a specific article
GET     /articles/:id/edit  edit    return an HTML form for editing a article
PUT     /articles/:id       update  update a specific article
DELETE  /articles/:id       destroy delete a specific article

However to make sure that the homepage routes to one of these actions you need to define root under config/routes.rb 但是,要确保主页路由到这些操作之一,您需要在config / routes.rb下定义root

root to: "articles#index"

Then commit and push it to heroku again. 然后提交并再次将其推送到heroku。

I notice that you're trying (probably unintentionally) to use an 'edge' version of rails (4+). 我注意到您正在尝试(可能无意间)使用“边缘”版本的滑轨(4+)。

I would stick with a 3.x version for now and that's what the tutorial is probably assuming. 我现在会坚持使用3.x版本,这可能就是本教程所假定的。

You can use this to create an app with a specific version (3.2 in this case) 您可以使用它来创建具有特定版本(在这种情况下为3.2)的应用

rails _3.2_ new myapp 

If you don't have that version of rails on your system you may need to install it, eg 如果您的系统上没有该版本的rails,则可能需要安装它,例如

gem install -v=3.2 rails

or, if that fails, 或者,如果失败,

sudo gem install rails -v3.2

The above is why, when you follow the current Heroku instructions it assumes rails 3 and that version does do that default root path and the public/index.html file 上面就是为什么,当您按照当前的Heroku指令进行操作时,它会假定Rails 3,并且该版本会执行默认的根路径和public / index.html文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM