> For the complete documentation index, see [llms.txt](https://teachersmanual.firstdraft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teachersmanual.firstdraft.com/projects-checklist/updating-old-projects-checklist.md).

# Updating Old Projects Checklist

## Root files

* Ensure `.ruby-version` exists in the root folder
* Add [default\_whitelist.yml](https://github.com/firstdraft/appdev_template/blob/master/files/default_whitelist.yml) to root folder
* Add [.gitpod.yml](https://github.com/firstdraft/appdev_template/blob/master/files/.gitpod.yml) to the root folder
* Ensure `Procfile` exists and looks like [this](https://github.com/appdev-projects/msm-api/blob/master/Procfile)
* **Un**gitignore `/db/*.sqlite3` and `/db/*.sqlite3-journal`
* Remove `circle.yml` file from the root folder if it exists.

## bin folder

* Replace `bin/setup` with [this](https://github.com/firstdraft/appdev_template/blob/master/files/setup)
* Ensure&#x20;

  ```
  system! "gem install bundler"
  system! "gem update bundler"
  ```

  is before `system! "bundle install"` in `bin/setup`.
* Ensure `bin/whitelist` exists and looks like [this](https://github.com/firstdraft/appdev_template/blob/master/files/whitelist)
* Ensure `bin/server` exists and looks like [this](https://github.com/firstdraft/appdev_template/blob/master/files/server)

## Initializers

* Add a file [nicer\_errors.rb](https://github.com/firstdraft/appdev_template/blob/master/files/nicer_errors.rb) to `config/initializers`
* Replace the out-of-the-box backtrack\_silencers.rb with [this](https://github.com/firstdraft/appdev_template/blob/aac1a4090a4d612a2efee4db9273e5fb40478140/template.rb#L227)
* Add a file [delegation\_monkey\_patch.rb](https://github.com/appdev-projects/msm-queries/commit/333d47137bfc512a98a55416aee29c3ce97e4301) to `config/initializers`
* Add a file [active\_record\_relation\_patch.rb](https://github.com/firstdraft/appdev_template/blob/master/files/active_record_relation_patch.rb) to `config/initializers`
* Add a file [attribute-methods-patch.rb](https://github.com/firstdraft/appdev_template/blob/master/files/attribute-methods-patch.rb) to `config/initializers`
* Add a file [fetch\_store\_patch.rb](https://github.com/firstdraft/appdev_template/blob/master/files/fetch_store_patch.rb) to `config/initializers`
* Ensure `open_uri.rb` in `config/initializers` looks like [this](https://github.com/appdev-projects/omnicalc-actions/blob/master/config/initializers/open_uri.rb)
* If `initializers/new_framework_defaults.rb` is present, remove it. Make sure that [updating the app](https://blog.bigbinary.com/2016/08/18/new-framework-defaults-in-rails-5-to-make-upgrade-easier.html) to a new Rails version did not break any behavior in the app.

## In application.rb

* Add the following line, `config.action_controller.default_protect_from_forgery = false`, after the `load_defaults`.
* Add the following line, `config.active_record.belongs_to_required_by_default = false`, after the `load_defaults`.
* Add the following line, `config.autoload_paths += %W(#{config.root}/app/vendor_models)`, after the `load_defaults`.
* Add the following line, `config.autoload_paths += Dir["#{config.root}/app/vendor_models/**/"]`, after the `load_defaults`.

  ```
  config.load_defaults *.*
  ...
  config.action_controller.default_protect_from_forgery = false
  config.active_record.belongs_to_required_by_default = false

  config.autoload_paths += %W(#{config.root}/vendor/app/models)
  ```

## Gems

```ruby
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'

gem 'rails', '~> 6.0.0'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bcrypt', '~> 3.1.7'

gem 'activeadmin', '2.2.0'
gem 'devise'
gem 'http'
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  gem 'awesome_print'
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'dotenv-rails'
  gem 'grade_runner', github: 'firstdraft/grade_runner'
  gem 'pry-rails'
  gem 'sqlite3', '~> 1.4'
  gem 'table_print'
  gem 'faker'
  gem 'web_git', github: 'firstdraft/web_git'
end

group :development do
  gem 'annotate', '< 3.0.0' 
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'draft_generators', github: 'firstdraft/draft_generators'
  gem 'letter_opener'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'meta_request'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'tty-spinner'
  gem 'web-console', '>= 3.3.0'
end

group :test do
  gem 'capybara', '>= 2.15'
  gem 'rspec-rails'
  gem 'rspec-html-matchers'
  gem 'selenium-webdriver'
  gem 'webmock'
  gem 'webdrivers'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
```

* Include Ruby version in `Gemfile`
* Remove `gem "console_ip_whitelist", github: "firstdraft/console_ip_whitelist"` to the development and test groups
* Move `sqlite3` gem to development and test groups
* Add `gem "tty-spinner"` to development group
* Ensure `gem "annotate", '< 3.0.0'` is present, if not add to the `Gemfile` and install it with `rails g annotate:install`
* Ensure `gem 'activeadmin', '2.2.0'` and `gem 'devise'` are using the RubyGems version instead of the GitHub.
* Add `gem "better_errors"` and `gem "binding_of_caller"` to the development and test groups
* Remove `gem "draft_log", github: "firstdraft/draft_log"` if it's present and `bundle`.
* Ensure that `gem "web_git", github: "firstdraft/web_git` is included. Start the server and ensure that navigating to `/git` works.
* Ensure all projects are ready to deploy to Heroku:

  ```ruby
    group :production do
      gem "pg"
      gem "rails_12factor"
    end
  ```

## General

* `git rm whitelist.yml` if present
* Ensure `whitelist.yml` is gitignored
* Ensure `dev_tools` is removed from `app/views/layouts/application.html.erb`
* Remove `cloud9_plugins.sh` if present, and remove its line from `gitignore`
* Ensure there is no tzinfo-data warning message when executing `rails` commands. If there is run:

  ```
  bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`
  ```
* Ensure `db:seeds` is doing `AdminUser.create` and not `AdminUser.create!`
* If `vendor/app/models/` doesn't exist create it
* Ensure `admin_user.rb` is **not** in the `app/models/` folder and is instead in `vendor/app/models/`
* Ensure any use of Hash#\[] changes to Hash#fetch in existing code
* Ensure that in `development.rb` the lines starting with `path = Rails.root.join('whitelist.yml')` and ending with `config.action_mailer.default_url_options = { host: "localhost", port: 3000 }` (non-inclusive) is replaced with:

  ```ruby
      path = Rails.root.join("whitelist.yml")
      default_whitelist_path = Rails.root.join("default_whitelist.yml")
      whitelisted_ips = []
      if File.exist?(path)
        whitelisted_ips = YAML.load_file(path)
      end
      if File.exist?(default_whitelist_path)
        whitelisted_ips = whitelisted_ips.concat(YAML.load_file(default_whitelist_path))
      end
      config.web_console.permissions = whitelisted_ips
      config.web_console.whiny_requests = false

      BetterErrors::Middleware.allow_ip! '10.138.0.0/16'
  ```
* Make sure the project setup steps in README are [modern](https://github.com/firstdraft/appdev_template/blob/master/files/README.md)
* `bundle update` with the **same** minor Rails version
* Make sure templates are explicitly rendered with the folder name, e.g. `render("photo_templates/show.html.erb")`
* Make sure tests are all isolated in their own describe block that contains the action path, e.g "/coffee\_beans" instead of "coffee beans index"
* Make sure all tests that have only\_path: true get replaced with ignore\_query: true
* Get rid of `//= require_tree` . in application.js
* Get rid of `*= require_tree` . in application.css
* Ensure that all targets have a rake task that runs every hour or so to reset the dev:prime data (since students fill it with garbage)
* Open the project in Gitpod, ensure that `bin/setup` completes, navigate to `/git`, `/admin` and ensure you can login. Ensure you can run `rails grade` without errors.
