DEV Community

DavidNNussbaum
DavidNNussbaum

Posted on

A Quick Guide To Setting Up a Rails Directory

First create a new repo on github.

In your terminal, cd to the directory in which you want the rails directory to reside. Please note the words directory, file-name, YourName, ModelName, and column_name are being used as generic terms to be replaced with the actual names that you are using.

Now enter:
*~/directory$ rails new file-name -T --database=postgresql --no-test-framework *
Please note that if you do not enter -T --database=postgresql, to install PostgreSQL then the default database is SQLite.

If you do not enter --no-test-framework then the default is to include the extra test files.

Next cd to the created rails file:

~/directory$ cd file-name

The next steps will allow you to push your changes to github. Enter the following with everything after the word origin being a copy of the SSH from your github repo.

~/directory/file-name$ git remote add origin git@github.com:YourName/file-name.git

Next enter:

~/directory/file-name$ git branch

Followed by:
~/directory/file-name$ git status
The following will appear in the terminal:
On branch master

No commits yet

Next add (the period after a space is part of the entry):

~/directory/file-name$ git add .

Followed by:

~/directory/file-name$ git commit -m "Setting up the file."

Then enter:
~/directory/file-name$ git status
The following will appear in the terminal:
On branch master

nothing to commit, working tree clean

Next enter:

~/directory/file-name$ git branch -M master

Followed by:

~/directory/file-name$ git push -u origin master

Next enter:

~/directory/file-name$ git pull origin master --allow-unrelated-histories

Followed by:

~/directory/file-name$ git push --set-upstream origin master

If you are installing PostgreSQL enter, otherwise skip this step:

*~/directory/file-name$ gem install pg *

No matter what your database is the next step is:

~/directory/file-name$ bundle install

Followed by:

~/directory/file-name$ rails db:create

To set up each model enter:
~/directory/file-name$ rails g model ModelName column_name:type foreign_key:references
Please note that you can add in as many columns as are present for this model. The references term will create a column called whatever the foreign key is with _id attached.

Thanks for reading!

Image of Timescale

📊 Benchmarking Databases for Real-Time Analytics Applications

Benchmarking Timescale, Clickhouse, Postgres, MySQL, MongoDB, and DuckDB for real-time analytics. Introducing RTABench 🚀

Read full post →

Top comments (0)

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • --last-failed: Zero in on just the tests that failed in your previous run
  • --only-changed: Test only the spec files you've modified in git
  • --repeat-each: Run tests multiple times to catch flaky behavior before it reaches production
  • --forbid-only: Prevent accidental test.only commits from breaking your CI pipeline
  • --ui --headed --workers 1: Debug visually with browser windows and sequential test execution

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Practical examples included!

Watch Video 📹ī¸

👋 Kindness is contagious

DEV shines when you're signed in, unlocking a customized experience with features like dark mode!

Okay