我正在尝试将我的Rails 5应用程序部署到Heroku。我刚刚设置了mLab,但是我的Heroku应用程序页面上写着"肯定存在错误。#34;
我按照说明seen here。我虽然是初学者,所以我并不完全理解我所做的一切,完全诚实。
这是我的宝石文件,以防万一:
source 'https://rubygems.org'
gem 'rails', '5.0.1'
gem 'puma', '3.4.0'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.2.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.4.1'
group :development, :test do
gem 'mongoid', '6.1.0'
gem 'bson_ext'
gem 'byebug', '9.0.0', platform: :mri
end
group :development do
gem 'web-console', '3.1.1'
gem 'listen', '3.0.8'
gem 'spring', '1.7.2'
gem 'spring-watcher-listen', '2.0.0'
end
group :test do
gem 'rails-controller-testing', '0.1.1'
gem 'minitest-reporters', '1.1.9'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
end
group :production do
gem 'rails_12factor'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
mongoid.yml的相关部分:
# mongoid
#
production:
clients:
default:
# The standard MongoDB connection URI allows for easy
# replica set connection setup.
# Use environment variables or a config file to keep your
# credentials safe e.g. <%= ENV['MONGODB_URI'] %>.
uri: <%= ENV['MONGOLAB_URI'] %>
options:
# The default timeout is 5, which is the time in seconds
# for a connection to time out.
# We recommend 15 because it allows for plenty of time
# in most operating environments.
connect_timeout: 15
最后我的Heroku记录:
2017-03-14T10:29:02.337819+00:00 app[web.1]: * Version 3.4.0 (ruby 2.2.6-p396), codename: Owl Bowl Brawl
2017-03-14T10:29:02.337838+00:00 app[web.1]: * Environment: production
2017-03-14T10:29:02.337956+00:00 app[web.1]: * Listening on tcp://0.0.0.0:13166
2017-03-14T10:29:02.338149+00:00 app[web.1]: Use Ctrl-C to stop
2017-03-14T10:29:54.966609+00:00 app[api]: Detach DATABASE (@ref:postgresql-lively-51943) by user ellis.jas48@gmail.com
2017-03-14T10:29:54.966609+00:00 app[api]: Release v9 created by user ellis.jas48@gmail.com
2017-03-14T10:29:55.462644+00:00 app[api]: Release v9 created by user ellis.jas48@gmail.com
2017-03-14T10:29:55.561366+00:00 heroku[web.1]: Restarting
2017-03-14T10:29:55.561865+00:00 heroku[web.1]: State changed from up to starting
2017-03-14T10:29:56.262337+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-03-14T10:29:56.276153+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-03-14T10:29:56.276275+00:00 app[web.1]: === puma shutdown: 2017-03-14 10:29:56 +0000 ===
2017-03-14T10:29:56.276277+00:00 app[web.1]: - Goodbye!
2017-03-14T10:29:56.276361+00:00 app[web.1]: Exiting
2017-03-14T10:29:56.401600+00:00 heroku[web.1]: Process exited with status 0
2017-03-14T10:29:59.161344+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 17091 -e production`
2017-03-14T10:30:03.899834+00:00 app[web.1]: => Rails 5.0.1 application starting in production on http://0.0.0.0:17091
2017-03-14T10:30:03.899797+00:00 app[web.1]: => Booting Puma
2017-03-14T10:30:03.899835+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-03-14T10:30:05.128451+00:00 app[web.1]: Puma starting in single mode...
2017-03-14T10:30:05.128523+00:00 app[web.1]: * Version 3.4.0 (ruby 2.2.6-p396), codename: Owl Bowl Brawl
2017-03-14T10:30:05.128562+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-03-14T10:30:05.128624+00:00 app[web.1]: * Environment: production
2017-03-14T10:30:05.128812+00:00 app[web.1]: * Listening on tcp://0.0.0.0:17091
2017-03-14T10:30:05.129253+00:00 app[web.1]: Use Ctrl-C to stop
2017-03-14T10:30:05.712457+00:00 heroku[web.1]: State changed from starting to up
2017-03-14T11:01:53.466180+00:00 heroku[web.1]: Idling
2017-03-14T11:01:53.466824+00:00 heroku[web.1]: State changed from up to down
2017-03-14T11:01:54.158015+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-03-14T11:01:54.172597+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-03-14T11:01:54.172605+00:00 app[web.1]: === puma shutdown: 2017-03-14 11:01:54 +0000 ===
2017-03-14T11:01:54.172607+00:00 app[web.1]: - Goodbye!
2017-03-14T11:01:54.172608+00:00 app[web.1]: Exiting
2017-03-14T11:01:54.352041+00:00 heroku[web.1]: Process exited with status 0
2017-03-14T11:06:04.603021+00:00 heroku[web.1]: Unidling
2017-03-14T11:06:04.603286+00:00 heroku[web.1]: State changed from down to starting
2017-03-14T11:06:07.426080+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 43385 -e production`
2017-03-14T11:06:11.300942+00:00 app[web.1]: => Booting Puma
2017-03-14T11:06:11.300974+00:00 app[web.1]: => Rails 5.0.1 application starting in production on http://0.0.0.0:43385
2017-03-14T11:06:11.300975+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-03-14T11:06:12.172201+00:00 app[web.1]: Puma starting in single mode...
2017-03-14T11:06:12.172221+00:00 app[web.1]: * Version 3.4.0 (ruby 2.2.6-p396), codename: Owl Bowl Brawl
2017-03-14T11:06:12.172252+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-03-14T11:06:12.172297+00:00 app[web.1]: * Environment: production
2017-03-14T11:06:12.172395+00:00 app[web.1]: * Listening on tcp://0.0.0.0:43385
2017-03-14T11:06:12.172620+00:00 app[web.1]: Use Ctrl-C to stop
2017-03-14T11:06:12.284924+00:00 heroku[web.1]: State changed from starting to up
2017-03-14T11:06:12.661213+00:00 heroku[router]: at=info method=GET path="/" host=aqueous-dawn-54394.herokuapp.com request_id=a02ddf92-7774-40c4-854b-8fc4fe466f0e fwd="115.70.240.190" dyno=web.1 connect=0ms service=5ms status=404 bytes=1744 protocol=https
2017-03-14T11:06:12.667112+00:00 app[web.1]: I, [2017-03-14T11:06:12.667025 #4] INFO -- : [a02ddf92-7774-40c4-854b-8fc4fe466f0e] Started GET "/" for 115.70.240.190 at 2017-03-14 11:06:12 +0000
2017-03-14T11:06:12.669277+00:00 app[web.1]: F, [2017-03-14T11:06:12.669224 #4] FATAL -- : [a02ddf92-7774-40c4-854b-8fc4fe466f0e] ActionController::RoutingError (uninitialized constant PeopleController):
2017-03-14T11:06:12.669228+00:00 app[web.1]: F, [2017-03-14T11:06:12.669159 #4] FATAL -- : [a02ddf92-7774-40c4-854b-8fc4fe466f0e]
2017-03-14T11:06:12.669326+00:00 app[web.1]: F, [2017-03-14T11:06:12.669278 #4] FATAL -- : [a02ddf92-7774-40c4-854b-8fc4fe466f0e]
2017-03-14T11:06:12.669418+00:00 app[web.1]: F, [2017-03-14T11:06:12.669350 #4] FATAL -- : [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/inflector/methods.rb:268:in `const_get'
2017-03-14T11:06:12.669420+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/inflector/methods.rb:268:in `block in constantize'
2017-03-14T11:06:12.669421+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/inflector/methods.rb:266:in `each'
2017-03-14T11:06:12.669422+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/inflector/methods.rb:266:in `inject'
2017-03-14T11:06:12.669422+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/inflector/methods.rb:266:in `constantize'
2017-03-14T11:06:12.669423+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:583:in `get'
2017-03-14T11:06:12.669424+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:614:in `constantize'
2017-03-14T11:06:12.669424+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/http/request.rb:81:in `controller_class'
2017-03-14T11:06:12.669425+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/routing/route_set.rb:44:in `controller'
2017-03-14T11:06:12.669426+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/routing/route_set.rb:30:in `serve'
2017-03-14T11:06:12.669427+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/journey/router.rb:39:in `block in serve'
2017-03-14T11:06:12.669428+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/journey/router.rb:26:in `each'
2017-03-14T11:06:12.669428+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/journey/router.rb:26:in `serve'
2017-03-14T11:06:12.669429+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/routing/route_set.rb:725:in `call'
2017-03-14T11:06:12.669431+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/etag.rb:25:in `call'
2017-03-14T11:06:12.669432+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/head.rb:12:in `call'
2017-03-14T11:06:12.669432+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/conditional_get.rb:25:in `call'
2017-03-14T11:06:12.669433+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:222:in `context'
2017-03-14T11:06:12.669434+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:216:in `call'
2017-03-14T11:06:12.669435+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/cookies.rb:613:in `call'
2017-03-14T11:06:12.669435+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
2017-03-14T11:06:12.669437+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
2017-03-14T11:06:12.669436+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
2017-03-14T11:06:12.669437+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/callbacks.rb:90:in `run_callbacks'
2017-03-14T11:06:12.669438+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
2017-03-14T11:06:12.669439+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
2017-03-14T11:06:12.669439+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
2017-03-14T11:06:12.669440+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
2017-03-14T11:06:12.669444+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/rack/logger.rb:36:in `call_app'
2017-03-14T11:06:12.669445+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:in `block in call'
2017-03-14T11:06:12.669446+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/tagged_logging.rb:69:in `block in tagged'
2017-03-14T11:06:12.669447+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/tagged_logging.rb:26:in `tagged'
2017-03-14T11:06:12.669447+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/tagged_logging.rb:69:in `tagged'
2017-03-14T11:06:12.669448+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:in `call'
2017-03-14T11:06:12.669449+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/request_id.rb:24:in `call'
2017-03-14T11:06:12.669450+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call'
2017-03-14T11:06:12.669450+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/method_override.rb:22:in `call'
2017-03-14T11:06:12.669452+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
2017-03-14T11:06:12.669453+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/executor.rb:12:in `call'
2017-03-14T11:06:12.669453+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/static.rb:136:in `call'
2017-03-14T11:06:12.669454+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call'
2017-03-14T11:06:12.669455+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/configuration.rb:224:in `call'
2017-03-14T11:06:12.669454+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:522:in `call'
2017-03-14T11:06:12.669456+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:569:in `handle_request'
2017-03-14T11:06:12.669457+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:271:in `block in run'
2017-03-14T11:06:12.669457+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:406:in `process_client'
2017-03-14T11:06:12.669458+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `call'
2017-03-14T11:06:12.669459+00:00 app[web.1]: [a02ddf92-7774-40c4-854b-8fc4fe466f0e] vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `block in spawn_thread'
2017-03-14T11:06:12.981986+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=aqueous-dawn-54394.herokuapp.com request_id=206b3bd5-6187-4397-b56e-6f89628f323f fwd="115.70.240.190" dyno=web.1 connect=7ms service=1ms status=304 bytes=48 protocol=https
我知道这很重要,非常感谢任何回复的人!
编辑:这是routes.rb:
Rails.application.routes.draw do
resources :people, except: [:show]
root to: "people#index"
end
people_controller.rb:
class PeopleController < ApplicationController
def index
@people = Person.all
end
def new
@person = Person.new
end
def create
@person = Person.new(person_params)
if @person.save
redirect_to people_path, notice: "The person has been created!" and return
end
render 'new'
end
def edit
@person = Person.find(params[:id])
end
def update
@person = Person.find(params[:id])
if @person.update_attributes(person_params)
redirect_to people_path, notice: "#{@person.first_name} #{@person.last_name} has been updated!" and return
end
render 'edit'
end
def destroy
@person = Person.find(params[:id])
@person.destroy
redirect_to people_path, notice: "#{@person.first_name} #{@person.last_name} has been deleted!" and return
end
private
def person_params
params.require(:person).permit(:first_name, :last_name, :email, :notes)
end
end