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

Chr*_*s A 3 ruby-on-rails ruby-on-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
Run Code Online (Sandbox Code Playgroud)

Chr*_*s A 7

要在现有项目中复制设置,请按照此答案skip-active-record中的步骤操作

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

删除配置/环境/生产.rb - >config.active_storage.service = :local

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

删除垃圾箱/设置-> puts "\n== Preparing database ==" system! 'bin/rails db:prepare'

删除配置/存储.yml

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