【发布时间】:2017-08-08 17:33:26
【问题描述】:
我的应用程序在本地工作,但我在尝试将其推送到 Heroku 时遇到问题。我在我的 Rails 5 应用程序中使用 mLab 和 Mongoid。当我进入时:
git push heroku 大师
我收到以下错误:
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 工作正常。
这是我的 config/application.rb 文件:
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:
require_relative 'config/application'
Rails.application.load_tasks
如果需要,这里是 mongoid.yml 的生产部分:
# mongoid
#
production:
clients:
default:
uri: mongodb://<username>:<password>@ds133340.mlab.com:33340/okclone
options:
connect_timeout: 15
注意:我在上面的 uri 中输入了我的实际用户名和密码。
还有我的 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]
编辑:我也尝试过运行
heroku 配置:设置 PROD_MONGODB = mongodb://dbuser:dbpass@host1:port1,host2:port2/dbname
添加了我的 mLab URI,但这似乎无法解决问题。
【问题讨论】:
-
哦,好的,会的。
标签: ruby-on-rails mongodb heroku mongoid mlab