【问题标题】:How to skip active record for existing project in Rails 6如何在 Rails 6 中跳过现有项目的活动记录
【发布时间】:2020-05-19 08:02:24
【问题描述】:
我有一个现有的 Rails 项目,它是在 API 模式下创建的,没有使用 DB。在尝试部署到 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
【问题讨论】:
标签:
ruby-on-rails
ruby-on-rails-6
【解决方案1】:
要在现有项目中复制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