如何跳过 Rails 6 中现有项目的活动记录

How to skip active record for existing project in Rails 6

我有一个现有的 Rails 项目,它是我在 API 模式下创建的,不使用数据库。在尝试部署到 Heroku 时,我遇到了很多与 ActiveRecord 相关的错误。

-----> 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 设置,请按照 this answer

中的步骤操作

加上

删除 config/environments/development.rb -> config.active_storage.service = :local

删除 config/environments/production.rb -> config.active_storage.service = :local

删除 config/environments/test.rb -> config.active_storage.service = :local

删除 bin/setup -> puts "\n== Preparing database ==" system! 'bin/rails db:prepare'

删除config/storage.yml

删除 test/test_helper.rb # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all