问题
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
回答1:
To replicate the skip-active-record
setup in an existing project, follow the steps in this answer
PLUS
REMOVE config/environments/development.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 bin/setup -> puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
DELETE config/storage.yml
REMOVE test/test_helper.rb # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
来源:https://stackoverflow.com/questions/60041360/how-to-skip-active-record-for-existing-project-in-rails-6