내 응용 프로그램이 로컬로 작동하지만 문제를 Heroku에 전달하려고합니다. 내 Rails 5 응용 프로그램에서 mLab 및 Mongoid를 사용하고 있습니다. 내가 입력하는 경우 :Heroku 오류 - NameError : 초기화되지 않은 상수 PracticeApp :: Application :: Mongoid
git push heroku master
을 나는 다음과 같은 오류를 얻을 :
r.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
remote: ensure you can run `$ bundle exec rake -P` against your app
remote: and using the production group of your Gemfile.
remote: rake aborted!
remote: NameError: uninitialized constant PracticeApp::Application::Mongoid
remote: /tmp/build_7a8e6644d3ecbd6336fe612855f87f95/practice_app/config/application.rb:21:in `<class:Application>'
remote: /tmp/build_7a8e6644d3ecbd6336fe612855f87f95/practice_app/config/application.rb:20:in `<module:PracticeApp>'
remote: /tmp/build_7a8e6644d3ecbd6336fe612855f87f95/practice_app/config/application.rb:19:in `<top (required)>'
remote: /tmp/build_7a8e6644d3ecbd6336fe612855f87f95/practice_app/Rakefile:4:in `require_relative'
remote: /tmp/build_7a8e6644d3ecbd6336fe612855f87f95/practice_app/Rakefile:4:in `<top (required)>'
bundle exec rake -P
가 잘 작동합니다. 여기
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module PracticeApp
class Application < Rails::Application
Mongoid.load!("./config/mongoid.yml", :production)
end
end
내 rakefile :
# mongoid
#
production:
clients:
default:
uri: mongodb://<username>:<password>@ds133340.mlab.com:33340/okclone
options:
connect_timeout: 15
: 경우는 여기에 필요한에서
require_relative 'config/application'
Rails.application.load_tasks
이 mongoid.yml의 생산 부분
참고 : 나는 실제 사용자 이름과 암호를 uri ab에 넣었습니다. 비켜.
그리고 내 gemfile는 경우에는 관련이 :
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]
편집 : 나는 또한 MLAB URI가 문제를 해결하는 것 같지 않았어요하지만 추가 내와
를 실행했습니다.heroku config:set PROD_MONGODB = mongodb://dbuser:[email protected]:port1,host2:port2/dbname
오케이. – xeno7