我创建了一个自定义的gem并将其推送到rubygems.org。在我的本地环境中,我可以要求自定义gem而不出现任何错误,但是当我推送到heroku master时,会收到此日志。我不太确定为什么会收到此错误,当我最初提交到heroku master时,它会弹出,当我导航到我的应用程序时,我会收到503错误。
关于我为什么会收到此错误的任何想法?预先感谢。
从Heroku登录
2019-03-30T16:47:30.163742+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 11391 -e production`
2019-03-30T16:47:36.645065+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-30T16:47:36.559861+00:00 app[web.1]: /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': No such file to load -- calculateprice.rb (LoadError)
2019-03-30T16:47:36.559903+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
2019-03-30T16:47:36.559905+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
2019-03-30T16:47:36.559907+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
2019-03-30T16:47:36.559909+00:00 app[web.1]: from /app/app/controllers/bookings_controller.rb:1:in `<main>'
2019-03-30T16:47:36.559910+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2019-03-30T16:47:36.559967+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2019-03-30T16:47:36.559970+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
2019-03-30T16:47:36.559971+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2019-03-30T16:47:36.559973+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2019-03-30T16:47:36.559974+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
2019-03-30T16:47:36.559976+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
2019-03-30T16:47:36.559977+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
2019-03-30T16:47:36.559985+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:378:in `block in require_or_load'
2019-03-30T16:47:36.559987+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'
2019-03-30T16:47:36.559989+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
2019-03-30T16:47:36.559996+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
2019-03-30T16:47:36.559997+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
2019-03-30T16:47:36.559999+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:37:in `load_interlock'
2019-03-30T16:47:36.560001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:356:in `require_or_load'
2019-03-30T16:47:36.560002+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `block in require_or_load'
2019-03-30T16:47:36.560004+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
2019-03-30T16:47:36.560005+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:47:in `require_or_load'
2019-03-30T16:47:36.560007+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:334:in `depend_on'
2019-03-30T16:47:36.560008+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:86:in `block in depend_on'
2019-03-30T16:47:36.560010+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
2019-03-30T16:47:36.560011+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:86:in `rescue in depend_on'
2019-03-30T16:47:36.560013+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:81:in `depend_on'
2019-03-30T16:47:36.560014+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:246:in `require_dependency'
2019-03-30T16:47:36.560016+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'
2019-03-30T16:47:36.560028+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:477:in `each'
2019-03-30T16:47:36.560033+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:477:in `block in eager_load!'
2019-03-30T16:47:36.560035+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:475:in `each'
2019-03-30T16:47:36.560036+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:475:in `eager_load!'
2019-03-30T16:47:36.560038+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:356:in `eager_load!'
2019-03-30T16:47:36.560039+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application/finisher.rb:69:in `each'
2019-03-30T16:47:36.560041+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
2019-03-30T16:47:36.560042+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:32:in `instance_exec'
2019-03-30T16:47:36.560043+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:32:in `run'
2019-03-30T16:47:36.560045+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
2019-03-30T16:47:36.560046+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
2019-03-30T16:47:36.560048+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2019-03-30T16:47:36.560049+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
2019-03-30T16:47:36.560051+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
2019-03-30T16:47:36.560057+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `each'
2019-03-30T16:47:36.560059+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `call'
2019-03-30T16:47:36.560061+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
2019-03-30T16:47:36.560062+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
2019-03-30T16:47:36.560064+00:00 app[web.1]: from /app/vendor/ruby-2.5.3/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
2019-03-30T16:47:36.560065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:60:in `run_initializers'
2019-03-30T16:47:36.560067+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application.rb:361:in `initialize!'
2019-03-30T16:47:36.560068+00:00 app[web.1]: from /app/config/environment.rb:5:in `<main>'
2019-03-30T16:47:36.560070+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2019-03-30T16:47:36.560076+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2019-03-30T16:47:36.560077+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
2019-03-30T16:47:36.560079+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2019-03-30T16:47:36.560081+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2019-03-30T16:47:36.560082+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
2019-03-30T16:47:36.560084+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
2019-03-30T16:47:36.560085+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
2019-03-30T16:47:36.560087+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
2019-03-30T16:47:36.560089+00:00 app[web.1]: from config.ru:3:in `block in <main>'
2019-03-30T16:47:36.560090+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'
2019-03-30T16:47:36.560092+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
2019-03-30T16:47:36.560093+00:00 app[web.1]: from config.ru:in `new'
2019-03-30T16:47:36.560095+00:00 app[web.1]: from config.ru:in `<main>'
2019-03-30T16:47:36.560097+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in `eval'
2019-03-30T16:47:36.560098+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in `new_from_string'
2019-03-30T16:47:36.560100+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:40:in `parse_file'
2019-03-30T16:47:36.560101+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2019-03-30T16:47:36.560103+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:219:in `app'
2019-03-30T16:47:36.560105+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/commands/server/server_command.rb:27:in `app'
2019-03-30T16:47:36.560106+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:354:in `wrapped_app'
2019-03-30T16:47:36.560107+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:283:in `start'
2019-03-30T16:47:36.560109+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/commands/server/server_command.rb:53:in `start'
2019-03-30T16:47:36.560113+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/commands/server/server_command.rb:147:in `block in perform'
2019-03-30T16:47:36.560115+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/commands/server/server_command.rb:142:in `tap'
2019-03-30T16:47:36.560119+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/commands/server/server_command.rb:142:in `perform'
2019-03-30T16:47:36.560120+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
2019-03-30T16:47:36.560124+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
2019-03-30T16:47:36.560128+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
2019-03-30T16:47:36.560259+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/command/base.rb:65:in `perform'
2019-03-30T16:47:36.560265+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/command.rb:46:in `invoke'
2019-03-30T16:47:36.560273+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/commands.rb:18:in `<main>'
2019-03-30T16:47:36.560275+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2019-03-30T16:47:36.560279+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2019-03-30T16:47:36.560287+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
2019-03-30T16:47:36.560292+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2019-03-30T16:47:36.560302+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2019-03-30T16:47:36.560304+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
2019-03-30T16:47:36.560308+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
2019-03-30T16:47:36.560310+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
2019-03-30T16:47:36.560312+00:00 app[web.1]: from bin/rails:4:in `<main>'
2019-03-30T16:47:36.572688+00:00 app[web.1]: => Booting Puma
2019-03-30T16:47:36.572693+00:00 app[web.1]: => Rails 5.2.2.1 application starting in production
2019-03-30T16:47:36.572695+00:00 app[web.1]: => Run `rails server -h` for more startup options
2019-03-30T16:47:36.572697+00:00 app[web.1]: Exiting
2019-03-30T16:47:36.627563+00:00 heroku[web.1]: Process exited with status 1
2019-03-30T16:47:41.350974+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=protected-falls-69943.herokuapp.com request_id=9745ba5a-4750-4796-87f8-322553d26741 fwd="193.1.209.152" dyno= connect= service= status=503 bytes= protocol=https
2019-03-30T16:47:42.742496+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=protected-falls-69943.herokuapp.com request_id=43c860fb-371c-4249-b3b6-034657072100 fwd="193.1.209.152" dyno= connect= service= status=503 bytes= protocol=https
Bookings_controller.rb-gem在此控制器的顶部被调用,并在该控制器的def create方法中实现
require 'calculateprice'
def create
@booking = Booking.new(booking_params)
@booking.user_id = current_user.id
@booking.price = CalculatePrice.calculate_price(@booking.lot, @booking.duration)
respond_to do |format|
if @booking.save
format.html { redirect_to @booking, notice: 'Booking was successfully created.' }
format.json { render :show, status: :created, location: @booking }
else
format.html { render :new }
format.json { render json: @booking.errors, status: :unprocessable_entity }
end
end
end
calculateprice.rb-我的自定义宝石
require 'singleton'
class CalculatePrice
include Singleton
def self.calculate_price(lot, duration)
if lot == "basketball"
hourlyRate = 12
elsif lot == "football"
hourlyRate = 10
elsif lot == "squash"
hourlyRate = 9
elsif lot == "tennis"
hourlyRate = 7.5
elsif lot == "golf"
hourlyRate = 10
elsif lot == "gym"
hourlyRate = 6.5
elsif lot == "swimming pool"
hourlyRate = 5
end
finalPrice = duration*hourlyRate
return finalPrice
end
end
宝石文件
gem 'calculateprice', '~> 0.0.0'