我是新手 需要帮助,以显示我对heroku的部署有什么问题。 这是heroku上的测试链接点击https://stableform4.herokuapp.com/ 问题是:
我不知道如何解决这个问题,请问,有没有人可以帮我解决这个问题?
这是我的gemfile:
source 'https://rubygems.org'
ruby '2.3.0'
gem 'rails', '4.2.5'
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bcrypt', '3.1.7'
group :development, :test do
gem 'byebug'
gem 'pry'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end

这是我的' heroku日志'
yoskakomba:~/workspace (master) $ heroku logs
2016-03-17T01:59:48.800895+00:00 heroku[web.1]: State changed from starting to up
2016-03-17T01:59:49.109588+00:00 app[web.1]: => Booting WEBrick
2016-03-17T01:59:49.109598+00:00 app[web.1]: => Rails 4.2.5 application starting in production on http://0.0.0.0:37193
2016-03-17T01:59:49.109600+00:00 app[web.1]: => Ctrl-C to shutdown server
2016-03-17T01:59:49.109599+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-03-17T01:59:49.109601+00:00 app[web.1]: Started GET "/" for 139.193.121.119 at 2016-03-17 01:59:49 +0000
2016-03-17T01:59:49.152469+00:00 app[web.1]: Processing by LoginsController#new as HTML
2016-03-17T01:59:49.164862+00:00 app[web.1]: Rendered shared/_page_title.html.erb (0.3ms)
2016-03-17T01:59:49.165482+00:00 app[web.1]: Rendered logins/new.html.erb within layouts/application (2.9ms)
2016-03-17T01:59:49.190211+00:00 app[web.1]: Client Load (1.2ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT 1 [["id", 1]]
2016-03-17T01:59:49.203241+00:00 app[web.1]: Rendered layouts/_navigation.html.erb (35.4ms)
2016-03-17T01:59:49.204391+00:00 app[web.1]: Rendered layouts/_messages.html.erb (0.7ms)
2016-03-17T01:59:49.205755+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.7ms)
2016-03-17T01:59:49.206024+00:00 app[web.1]: Completed 200 OK in 53ms (Views: 36.1ms | ActiveRecord: 10.7ms)
2016-03-17T01:59:49.207719+00:00 heroku[router]: at=info method=GET path="/" host=stableform4.herokuapp.com request_id=46276eb3-6eaa-4e18-8260-2b51e7c4b709 fwd="139.193.121.119" dyno=web.1 connect=2ms service=104ms status=200 bytes=5248
2016-03-17T01:59:54.692610+00:00 heroku[router]: at=info method=GET path="/logout" host=stableform4.herokuapp.com request_id=91a7fe3b-0fc3-4dc5-a017-3b609a7bae68 fwd="139.193.121.119" dyno=web.1 connect=2ms service=12ms status=302 bytes=1119
2016-03-17T01:59:54.686439+00:00 app[web.1]: Started GET "/logout" for 139.193.121.119 at 2016-03-17 01:59:54 +0000
2016-03-17T01:59:54.689001+00:00 app[web.1]: Processing by LoginsController#destroy as HTML
2016-03-17T01:59:54.689700+00:00 app[web.1]: Redirected to https://stableform4.herokuapp.com/
2016-03-17T01:59:54.690247+00:00 app[web.1]: Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
2016-03-17T01:59:55.215672+00:00 heroku[router]: at=info method=GET path="/" host=stableform4.herokuapp.com request_id=e78735f7-914b-477f-adcc-ce83323db296 fwd="139.193.121.119" dyno=web.1 connect=1ms service=18ms status=200 bytes=4922
2016-03-17T01:59:55.202635+00:00 app[web.1]: Started GET "/" for 139.193.121.119 at 2016-03-17 01:59:55 +0000
2016-03-17T01:59:55.204506+00:00 app[web.1]: Processing by LoginsController#new as HTML
2016-03-17T01:59:55.207610+00:00 app[web.1]: Rendered shared/_page_title.html.erb (0.3ms)
2016-03-17T01:59:55.208417+00:00 app[web.1]: Rendered logins/new.html.erb within layouts/application (2.5ms)
2016-03-17T01:59:55.211095+00:00 app[web.1]: Rendered layouts/_navigation.html.erb (1.5ms)
2016-03-17T01:59:55.212567+00:00 app[web.1]: Rendered layouts/_messages.html.erb (0.4ms)
2016-03-17T01:59:55.213291+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.3ms)
2016-03-17T01:59:55.213486+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 8.2ms | ActiveRecord: 0.0ms)
2016-03-17T02:02:09.647931+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by ariel.kakomba@gmail.com
2016-03-17T02:02:12.807089+00:00 heroku[run.1529]: Awaiting client
2016-03-17T02:02:12.841273+00:00 heroku[run.1529]: Starting process with command `bundle exec rake db:migrate`
2016-03-17T02:02:13.097509+00:00 heroku[run.1529]: State changed from starting to up
2016-03-17T02:02:22.198991+00:00 heroku[run.1529]: Process exited with status 0
2016-03-17T02:02:22.214176+00:00 heroku[run.1529]: State changed from up to complete
2016-03-17T02:04:00.656899+00:00 heroku[router]: at=info method=GET path="/" host=stableform4.herokuapp.com request_id=a18b4e0e-4970-4811-9bf4-f0d8f62e0f63 fwd="139.193.121.119" dyno=web.1 connect=0ms service=13ms status=200 bytes=4604
2016-03-17T02:04:00.648236+00:00 app[web.1]: Started GET "/" for 139.193.121.119 at 2016-03-17 02:04:00 +0000
2016-03-17T02:04:00.650631+00:00 app[web.1]: Processing by LoginsController#new as HTML
2016-03-17T02:04:00.653352+00:00 app[web.1]: Rendered logins/new.html.erb within layouts/application (1.2ms)
2016-03-17T02:04:00.655566+00:00 app[web.1]: Rendered layouts/_messages.html.erb (0.1ms)
2016-03-17T02:04:00.652335+00:00 app[web.1]: Rendered shared/_page_title.html.erb (0.0ms)
2016-03-17T02:04:00.655364+00:00 app[web.1]: Rendered layouts/_navigation.html.erb (0.6ms)
2016-03-17T02:04:00.656716+00:00 app[web.1]: Completed 200 OK in 6ms (Views: 4.6ms | ActiveRecord: 0.0ms)
2016-03-17T02:04:00.656386+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.1ms)
2016-03-17T02:04:08.275043+00:00 heroku[router]: at=info method=POST path="/login" host=stableform4.herokuapp.com request_id=c71dfcb4-465c-4070-aea7-59a572158f7d fwd="139.193.121.119" dyno=web.1 connect=0ms service=91ms status=302 bytes=1058
2016-03-17T02:04:08.193729+00:00 app[web.1]: Started POST "/login" for 139.193.121.119 at 2016-03-17 02:04:08 +0000
2016-03-17T02:04:08.196792+00:00 app[web.1]: Processing by LoginsController#create as HTML
2016-03-17T02:04:08.201807+00:00 app[web.1]: Client Load (1.3ms) SELECT "clients".* FROM "clients" WHERE "clients"."email" = $1 LIMIT 1 [["email", "ariel.kakomba@gmail.com"]]
2016-03-17T02:04:08.196833+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"u9z0gLOM4sUnz3avEKbr0w6FIkl10mkyInOmB/Dlg6C3ZTJVnWWvdAeRA/Czs/8/ppzy58zoC6kX10mMQofhrA==", "email"=>"ariel.kakomba@gmail.com", "password"=>"[FILTERED]", "commit"=>"Login"}
2016-03-17T02:04:08.274341+00:00 app[web.1]: Completed 302 Found in 77ms (ActiveRecord: 1.3ms)
2016-03-17T02:04:08.273787+00:00 app[web.1]: Redirected to https://stableform4.herokuapp.com/enrollments
2016-03-17T02:04:08.577769+00:00 heroku[router]: at=info method=GET path="/enrollments" host=stableform4.herokuapp.com request_id=b97a0fa7-cee7-4533-a1a8-7dec6323bc90 fwd="139.193.121.119" dyno=web.1 connect=0ms service=15ms status=302 bytes=1226
2016-03-17T02:04:08.568413+00:00 app[web.1]: Started GET "/enrollments" for 139.193.121.119 at 2016-03-17 02:04:08 +0000
2016-03-17T02:04:08.572131+00:00 app[web.1]: Processing by EnrollmentsController#index as HTML
2016-03-17T02:04:08.575119+00:00 app[web.1]: Client Load (1.2ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT 1 [["id", 1]]
2016-03-17T02:04:08.576385+00:00 app[web.1]: Redirected to https://stableform4.herokuapp.com/clients/1
2016-03-17T02:04:08.576653+00:00 app[web.1]: Completed 302 Found in 4ms (ActiveRecord: 1.2ms)
2016-03-17T02:04:08.576503+00:00 app[web.1]: Filter chain halted as :authorize_admin rendered or redirected
2016-03-17T02:04:08.895391+00:00 heroku[router]: at=info method=GET path="/clients/1" host=stableform4.herokuapp.com request_id=26b63272-8010-4409-90a1-7f8ee71ca1f2 fwd="139.193.121.119" dyno=web.1 connect=0ms service=51ms status=200 bytes=5293
2016-03-17T02:04:08.848743+00:00 app[web.1]: Started GET "/clients/1" for 139.193.121.119 at 2016-03-17 02:04:08 +0000
2016-03-17T02:04:08.893270+00:00 app[web.1]: Rendered layouts/_navigation.html.erb (2.6ms)
2016-03-17T02:04:08.851602+00:00 app[web.1]: Processing by ClientsController#show as HTML
2016-03-17T02:04:08.884658+00:00 app[web.1]: (1.3ms) SELECT COUNT(*) FROM "enrollments" WHERE "enrollments"."client_id" = $1 [["client_id", 1]]
2016-03-17T02:04:08.893799+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.0ms)
2016-03-17T02:04:08.851684+00:00 app[web.1]: Parameters: {"id"=>"1"}
2016-03-17T02:04:08.854000+00:00 app[web.1]: Client Load (1.2ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT 1 [["id", 1]]
2016-03-17T02:04:08.879891+00:00 app[web.1]: Rendered shared/_page_title.html.erb (0.0ms)
2016-03-17T02:04:08.889033+00:00 app[web.1]: Rendered clients/show.html.erb within layouts/application (10.7ms)
2016-03-17T02:04:08.888057+00:00 app[web.1]: Enrollment Load (1.2ms) SELECT "enrollments".* FROM "enrollments" WHERE "enrollments"."client_id" = $1 ORDER BY "enrollments"."updated_at" DESC LIMIT 3 OFFSET 0 [["client_id", 1]]
2016-03-17T02:04:08.892373+00:00 app[web.1]: Client Load (1.1ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT 1 [["id", 1]]
2016-03-17T02:04:08.893569+00:00 app[web.1]: Rendered layouts/_messages.html.erb (0.1ms)
2016-03-17T02:04:08.894098+00:00 app[web.1]: Completed 200 OK in 42ms (Views: 16.6ms | ActiveRecord: 6.8ms)
2016-03-17T02:04:13.625835+00:00 app[web.1]: Started GET "/enrollments/new" for 139.193.121.119 at 2016-03-17 02:04:13 +0000
2016-03-17T02:04:13.630925+00:00 app[web.1]: Processing by EnrollmentsController#new as HTML
2016-03-17T02:04:13.697061+00:00 app[web.1]: Rendered shared/_errors.html.erb (1.2ms)
2016-03-17T02:04:13.635323+00:00 app[web.1]: Client Load (3.4ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT 1 [["id", 1]]
2016-03-17T02:04:13.726775+00:00 app[web.1]: Reference Load (3.1ms) SELECT "references".* FROM "references"
2016-03-17T02:04:13.687583+00:00 app[web.1]: Rendered shared/_page_title.html.erb (0.1ms)
2016-03-17T02:04:13.793988+00:00 app[web.1]: Rendered layouts/_navigation.html.erb (1.1ms)
2016-03-17T02:04:13.794563+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.0ms)
2016-03-17T02:04:13.757761+00:00 app[web.1]: Body Load (2.9ms) SELECT "bodies".* FROM "bodies"
2016-03-17T02:04:13.781981+00:00 app[web.1]: Health Load (6.7ms) SELECT "healths".* FROM "healths"
2016-03-17T02:04:13.794876+00:00 app[web.1]: Completed 200 OK in 164ms (Views: 78.4ms | ActiveRecord: 40.3ms)
2016-03-17T02:04:13.734171+00:00 app[web.1]: Preference Load (1.6ms) SELECT "preferences".* FROM "preferences"
2016-03-17T02:04:13.790775+00:00 app[web.1]: Rendered enrollments/new.html.erb within layouts/application (104.7ms)
2016-03-17T02:04:13.790668+00:00 app[web.1]: Rendered enrollments/_form.html.erb (101.6ms)
2016-03-17T02:04:13.794329+00:00 app[web.1]: Rendered layouts/_messages.html.erb (0.2ms)
2016-03-17T02:04:13.796363+00:00 heroku[router]: at=info method=GET path="/enrollments/new" host=stableform4.herokuapp.com request_id=f969711c-1377-46e0-9f8f-a938fe9abe3a fwd="139.193.121.119" dyno=web.1 connect=0ms service=181ms status=200 bytes=11068
2016-03-17T02:05:43.220836+00:00 heroku[router]: at=info method=POST path="/enrollments" host=stableform4.herokuapp.com request_id=ffb38afc-19bf-4860-b470-d45d7dd390dc fwd="139.193.121.119" dyno=web.1 connect=1ms service=32ms status=500 bytes=1754
2016-03-17T02:05:43.194475+00:00 app[web.1]: Started POST "/enrollments" for 139.193.121.119 at 2016-03-17 02:05:43 +0000
2016-03-17T02:05:43.196504+00:00 app[web.1]: Processing by EnrollmentsController#create as HTML
2016-03-17T02:05:43.196594+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"1QcLKJHSbPsEOKCrUFQgK4Tg/sQat8yADgiwyabhvZDZvs39vzshSiRm1fTzQTTHLPkuaqONrhs7rF9CFIPfnA==", "enrollment"=>{"name"=>"Yosafat", "last_name"=>"Kakomba", "dob"=>"06/08/1982", "suburb"=>"Bekasi", "address"=>"Perum Vila Nusa Indah 2 Blok CC2/18 Jatiasih", "telephone"=>"622182403788", "post_code"=>"16969", "occupation"=>"", "exercise"=>"Never", "private_health_fund"=>"", "newsletter"=>"yes", "reference_ids"=>[""], "my_friend"=>"Yosafat Kakomba", "preference_ids"=>[""], "body_ids"=>[""], "health_ids"=>[""], "past_medical_history"=>"", "medication"=>"", "symptoms"=>"", "terms"=>"1"}, "commit"=>"Submit"}
2016-03-17T02:05:43.198509+00:00 app[web.1]: Client Load (1.2ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT 1 [["id", 1]]
2016-03-17T02:05:43.217145+00:00 app[web.1]: (1.0ms) BEGIN
2016-03-17T02:05:43.221040+00:00 app[web.1]: (1.0ms) ROLLBACK
2016-03-17T02:05:43.221405+00:00 app[web.1]: Completed 500 Internal Server Error in 25ms (ActiveRecord: 8.5ms)
2016-03-17T02:05:43.222225+00:00 app[web.1]:
2016-03-17T02:05:43.222234+00:00 app[web.1]: RangeError (622182403788 is out of range for ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer with limit 4):
2016-03-17T02:05:43.222235+00:00 app[web.1]: app/controllers/enrollments_controller.rb:25:in `create'
2016-03-17T02:05:43.222258+00:00 app[web.1]:
2016-03-17T02:05:43.222259+00:00 app[web.1]:

非常感谢您的帮助
答案 0 :(得分:0)
错误:
RangeError (622182403788 is out of range for ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer with limit 4):
2016-03-17T02:05:43.222235+00:00 app[web.1]: app/controllers/enrollments_controller.rb:25:in `create'
2016-03-17T02:05:43.222258+00:00 app[web.1]:
这意味着您尝试将622182403788
的整数(数字)插入int
列,该列仅允许4
位。
看起来错误是由telephone
输入引起的:
"telephone"=>"622182403788"
解决方案是telephone
列的increase the limit
,或将telephone
输入限制为4个数字。
在处理Heroku时,您应该考虑以下几点:
WEBrick
- We use Puma
,但没有大量流量。我们的旧开发人员使用Unicorn
,两者都提供了并发性。如果您使用puma
,则在使用Windows开发应用时,最新版本会引发错误。我们的Procfile
如下:
# Procfile
web: bundle exec puma -C config/puma.rb
#config/puma.rb
########################################
####################
# Puma #
####################
########################################
# https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#adding-puma-to-your-application
if !ENV['RACK_ENV'] || ENV['RACK_ENV'] != 'development' #-> fixes "SIGTERM" error in Windows
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
end
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
########################################
Heroku
的日志是你最好的朋友 - 通过日志检查会告诉你到底发生了什么
使用“例外”gem - 替换Rails标准错误页面。我们已经开发exception_handler
来执行此操作,现在非常受欢迎:
您只需将其添加到Gemfile
即可获得生产中的完整异常消息/详细信息:
#Gemfile
gem "exception_handler"
它是完全可定制的,我们已经在Heroku上彻底测试了它 - 它适用于Rails 4& 5.
它应该比标准的“出问题”错误给你提供更多的工作。
<强>更新强>
对我而言,就像你的Reference
型号/表中没有任何记录一样。
原因是Heroku
意味着与开发系统不同的“环境”。因此,数据库应该是完全独立的。
您可以阅读有关setting up your databases in different environments here的更多信息。
-
需要考虑的重要一点是,因为您使用的是不同的数据库,所以production
数据库中不会包含任何数据。
您可以打开heroku console
:
# heroku run rails console
# refs = Reference.all
# -> should output all "Reference" records / objects
如果以上不显示任何对象,则必须填充它们。有两种方法可以做到这一点:
rake db:seed
如果您不想保留data integrity,则可以保持console
会话开放,并使用以下内容创建一些记录:
# Reference.create attribute: "value", attribute_2: "value"
这将为您手动创建记录。
执行此操作的“正确”方法是"seed" the database:
# db/seeds.rb
Reference.create name: "value", description: "value"
这将允许您从heroku控制台运行rake db:seed
:
# heroku run rails console
# rake db:seed