问题描述
我有一个在 API 模式下创建的现有 Rails 项目,不使用数据库.在尝试部署到 Heroku 时,我收到了许多与 ActiveRecord 相关的错误.
I have an existing Rails project which I created in API mode, using no DB. Upon trying to deploy to Heroku, I am getting lots of ActiveRecord related errors.
-----> Detecting rake tasks
!
! Could not detect rake tasks
! ensure you can run `$ bundle exec rake -P` against your app
! and using the production group of your Gemfile.
! rake aborted!
! URI::InvalidURIError: bad URI(is not URI?): ://user:pass@127.0.0.1/dbname
...
...
/activerecord-6.0.2.1/lib/active_record/railties/databases.rake
推荐答案
要在现有项目中复制 skip-active-record
设置,请按照 这个答案
To replicate the skip-active-record
setup in an existing project, follow the steps in this answer
加上
REMOVE config/environments/development.rb -> config.active_storage.service = :local
REMOVE config/environments/development.rb -> config.active_storage.service = :local
REMOVE config/environments/production.rb -> config.active_storage.service = :local
REMOVE config/environments/production.rb -> config.active_storage.service = :local
REMOVE config/environments/test.rb -> config.active_storage.service = :local
REMOVE config/environments/test.rb -> config.active_storage.service = :local
REMOVE bin/setup -> puts "\n== Preparing database =="系统!'bin/rails db:prepare'
REMOVE bin/setup -> puts "\n== Preparing database ==" system! 'bin/rails db:prepare'
删除config/storage.yml
REMOVE test/test_helper.rb # 在 test/fixtures/*.yml 中为所有测试按字母顺序设置所有装置.固定装置:全部
这篇关于如何跳过Rails 6中现有项目的活动记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!