My go to’s when starting a rails 7 project

Rob Faldo
2 min readApr 18, 2023

Mainly adding this here so I don’t have to keep remembering them when I start a new project!

  1. Make sure the most stable version of rails is installed rails -v
  2. Make sure the most stable version of ruby is installed rbenv versions and then rbenv local 3.2.2
  3. Make sure the most stable version of node is installed nvm list
  4. Make sure you have latest stable version of yarn yarn -v
  5. I always use heroku so I follow these docs but i use the following command to start the rails project
rails new APPNAMEHERE -c sass -j esbuild --database=postgresql -T

6. set the node engine in package.json

{
"name": "app",
"private": "true",
"dependencies": {
"@hotwired/stimulus": "^3.2.1",
"@hotwired/turbo-rails": "^7.3.0",
"esbuild": "^0.17.17",
"sass": "^1.62.0"
},
"scripts": {
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets",
"build:css": "sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules"
},
"engines": {
"node": "18.x"
}
}

7. set the heroku buildpacks

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs#latest
heroku buildpacks:set heroku/ruby --index 2

Check that buildpacks are set for ruby and node

robertfaldo$ heroku buildpacks
› Warning: heroku update available from 7.67.1 to 8.0.2.
=== marketing-assistant Buildpack URLs
1. https://github.com/heroku/heroku-buildpack-nodejs#latest
2. heroku/ruby

8. Add .idea/ to .gitignore to ignore my rubymine config stuff

9. Set up rspec

10. Add the following gems for debugging (and then run bundle)

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem 'rspec-rails', '~> 3.5'
gem 'pry-byebug'
gem 'pry-rails'
end

11. Add dot-env for managing environment variables locally

12. Enforce a node version by adding a .nvmrc file and then running

echo "18.6.0" > .nvmrc

13. Following parts of this awesome hotwire guide to set up simple form and CSS naming convention (also worth following as a crud guide using hotwire)

14. Buy a domain from https://www.cloudflare.com/en-gb/products/registrar/ (go to ‘Register domains’ on the left panel, i always struggle to find this one)

--

--