2015-05-20 59 views
0

當我運行'英雄本地'時,一切正常工作!如何解決這個問題以將Rails應用程序部署到Heroku?

但是,當我運行「的Heroku開放」,這是行不通的:

「你要找的頁面不存在,你可能打錯 地址或頁面可能已經移動。 。如果您是應用程序 所有者,請檢查日誌以獲取更多信息。「

這是我的Gemfile:

source 'https://rubygems.org' 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
ruby '2.2.1' 
gem 'rails', '4.0.2' 
gem 'puma' 
gem 'foreman' 

# Use postgresql as the database for Active Record 
gem 'pg' 

# Use SCSS for stylesheets 
gem 'sass-rails', '5.0.2' 

# 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', '~> 1.2' 

group :doc do 
    # bundle exec rake doc:rails generates the API under doc/api. 
    gem 'sdoc', require: false 
end 

這是Procfile:

web: bundle exec puma -e -p 5000 -S ~/puma -C config/puma.rb 

這是文件日誌:

2015-05-20T12:38:42.297654+00:00 app[web.1]: Started GET "/" for 183.81.86.77 at 2015-05-20 12:38:42 +0000 
2015-05-20T12:38:42.392427+00:00 app[web.1]: 
2015-05-20T12:38:42.392433+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 
2015-05-20T12:38:42.392437+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
2015-05-20T12:38:42.392445+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `tagged' 
2015-05-20T12:38:42.392435+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
2015-05-20T12:38:42.392452+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/request_id.rb:21:in `call' 
2015-05-20T12:38:42.392456+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.2/lib/active_support/cache/strategy/local_cache.rb:83:in `call' 
2015-05-20T12:38:42.392439+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:38:in `call_app' 
2015-05-20T12:38:42.392440+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `block in call' 
2015-05-20T12:38:42.392458+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/static.rb:64:in `call' 
2015-05-20T12:38:42.392459+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call' 
2015-05-20T12:38:42.392461+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.0.2/lib/rails/engine.rb:511:in `call' 
2015-05-20T12:38:42.392462+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.0.2/lib/rails/application.rb:97:in `call' 
2015-05-20T12:38:42.392463+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/configuration.rb:82:in `call' 
2015-05-20T12:38:42.392442+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `block in tagged' 
2015-05-20T12:38:42.392443+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:25:in `tagged' 
2015-05-20T12:38:42.392466+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/server.rb:375:in `process_client' 
2015-05-20T12:38:42.392467+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/server.rb:262:in `block in run' 
2015-05-20T12:38:42.392455+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' 
2015-05-20T12:38:42.392453+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' 
2015-05-20T12:38:42.392450+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `call' 
2015-05-20T12:38:42.392468+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/thread_pool.rb:104:in `call' 
2015-05-20T12:38:42.392470+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/thread_pool.rb:104:in `block in spawn_thread' 
2015-05-20T12:38:42.392472+00:00 app[web.1]: 
2015-05-20T12:38:42.392464+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-2.11.1/lib/puma/server.rb:507:in `handle_request' 
2015-05-20T12:38:42.392471+00:00 app[web.1]: 
2015-05-20T12:38:42.777619+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=bachvanngoc.herokuapp.com request_id=29570c12-9b74-4b70-b109-7365acb4938e fwd="183.81.86.77" dyno=web.1 connect=0ms service=2ms status=200 bytes=143 
2015-05-20T12:38:41.882707+00:00 heroku[web.1]: State changed from starting to up 
WARNING: Toolbelt v3.37.1 update available. 
+0

運行'heroku logs'檢查日誌;會給出一個錯誤的概念。 –

+0

謝謝,我更新了 – NeverSmile

+0

根據控制檯/日誌輸出,你沒有在你的'config/routes.rb'文件中定義一個基本路由(即''root':'some_controller#some_action'')。 –

回答

1

這不是一個問題,部署

從你的Heroku記錄似乎還沒有定義處理的根路徑的路線。

ActionController::RoutingError (No route matches [GET] "/"): 

如果你看看你的config/routes.rb文件,你需要定義一個控制器/動作來處理這條道路。

喜歡的東西:在開發過程中

root to: "acontroller#anaction" 

get "/" => "acontroller#anaction" 

的Rails在根路徑提供一個默認的頁面。如果您在生產環境中運行rails應用程序,則不會顯示此默認頁面。您可以通過執行rails server -e production在本地進行檢查,並且您會注意到,您沒有得到相同的主頁,但是與Heroku中獲得的頁面相同。

+0

非常感謝。我修好了它。 :)) – NeverSmile

0

你應該是在項目路徑,並運行:

heroku run rake db:create 

,並

heroku run db:migrate 

而且運行

heroku --help 

欲瞭解更多信息。

+0

謝謝,我之前運行過。我通過路由根固定錯誤:)) – NeverSmile

+0

@NeverSmile爲什麼你會選擇這個答案,如果它不是解決你的問題的那個.. –

+0

:))我選擇他們兩個,但是stackoverflow只在一個之後選擇。 – NeverSmile

相關問題