未找到Heroku Rails页面

时间:2013-04-13 13:14:14

标签: ruby-on-rails deployment heroku gemfile

我正在尝试在heroku上部署示例rails应用程序。创建一个非常基本的应用程序,添加一个git存储库,提交所有内容和“heroku创建”后,我将其推送到heroku。终端没有任何错误,但是当我用正确的地址打开浏览器时,我得到以下结果:

The page you were looking for doesn't exist.

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

我已经搜索了三个小时并使用了heroku教程如何部署应用程序,但我无法弄清楚我做错了什么。 这是我的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'

我已多次重复上述步骤,但没有奏效。谢谢!

编辑:添加了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

2 个答案:

答案 0 :(得分:6)

首先,有一本很好的指南on routing in Rails here

假设您的应用程序和文章控制器中有Article模型,您必须在config / routes.rb下定义此资源的路由。 Rails允许您在一行中添加index, show new, create, edit, updatedestroy的路由:

resources :articles

这将映射到以下内容:

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

但是要确保主页路由到其中一个操作,您需要在config / routes.rb下定义root

root to: "articles#index"

然后提交并再次将其推送到heroku。

答案 1 :(得分:1)

我注意到你正在尝试(可能是无意中)使用'edge'版本的rails(4 +)。

我现在坚持使用3.x版本,而这正是教程可能假设的。

您可以使用它来创建具有特定版本的应用程序(在本例中为3.2)

rails _3.2_ new myapp 

如果您的系统上没有该版本的rails,则可能需要安装它,例如

gem install -v=3.2 rails

或者,如果失败,

sudo gem install rails -v3.2

以上是为什么当你遵循当前的Heroku指令时它会假定rails 3并且该版本确实执行了默认的根路径和public / index.html文件