Home > Mobile >  How do I remove active record from an existing rails 7 site?
How do I remove active record from an existing rails 7 site?

Time:08-05

I have an existing Rails 7 site, and turns out I won't use active record or a database of any kind in it. How can I remove everything related to databases to lighten the site? Should I even bother doing it?

CodePudding user response:

I agree with @Eyeslandic, you can just ignore it, but if you really want, to delete it, the steps to do so are:

  1. Remove a gem that is responsible for database handling (mysql2, psql, whatever you have in Gemfile)

  2. Change your config/application.rb. If you have require rails/all you will need to remove it, and require only the parts you do need. If you want to see what those are exactly, create a new rails app where in setup you skip active record, and copy the require statements from there. The full list of what rails/all require is here I think Remove all config lines that go something likeconfig.active_record.... you find in the app

  3. Delete your config/database.yml file, db/schema.rb and migrations

  4. Adjust your test setup, remove database cleaners etc, this will depend on what test framework you have in the app (if any). Take fixtures into account if you have any

  5. search config/environments/* for any mentons of active_record and database config

  • Related