I always forget my last process for starting a greenfield rails app
me@jaykilleen.com wrote this about 6 years ago and it was last updated over 4 years ago.
rails new appname --webpack=vue -T -C -M -d postgresql
rails new appname --webpack=stimulus -d postgresql
rails new appname -T -C -M -d postgresql
-T skip the builtin testing framework.
-C skips Action Cable.
-M skips Action Mailer.
-d postgresql - configures for PostgreSQL
--api - Runs the Rails generator in the API mode, which sets us up for reading and writing JSON instead of pumping out HTML.
After installing postgresql remove the requirement to login using passwords.
CREATE ROLE jay WITH SUPERUSER CREATEDB LOGIN;;
sudo vim pg_hba.conf
Edit all login lines from peer
or md5
to trust
. This removes the requirement to login with a password. THIS SHOULD ONLY BE DONE FOR DEVELOPMENT.
Confirm with \du
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
jay | Superuser, Create DB, Cannot login | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
After you've added the user to the database.yml
file you can rails db:create
then go back to psql
and run \l
to list all the databases.
Start or Restart Postgresql with
sudo service postgresql start
sudo service postgresql stop