This is the base Graduate Academy debugging app (no errors - at least, not intentional). The following is a setup guide for new starters.
- Setup 💻
- Running the Application
In this setup, you will:
- Have all the necessary technology on your machine:
- Terminal (with Xcode installed)
- Homebrew
- VSCode
- Github account
- Github CLI
- Rbenv
- Ruby
-
Clone the Repository:
- If you need a refresher on how to setup your laptop, or want to do this again at another time, follow this tutorial: training_github_pages tutorial.
- Git clone the repository:
- Click on the green
<> Code
button. - Select
SSH
. - Copy the value, e.g.,
git@github.com:lambley/exam-grad-training-app.git
. - On your machine, in the folder you want this app to be in, use this command in your terminal:
git clone git@github.com:lambley/exam-grad-training-app.git
- Click on the green
-
Install rbenv:
- Ensure you have
rbenv
installed - this project usesRuby 3.3.0
. - Install via this command in your terminal (read more here):
brew install rbenv ruby-build # then run the following command after install is complete rbenv init
- Ensure you have
-
Install Ruby:
- Run the following command in your terminal to install the version of Ruby we're using (this will take a few minutes to install):
rbenv install 3.3.0
- Run the following command in your terminal to install the version of Ruby we're using (this will take a few minutes to install):
-
Verify Ruby Installation:
- To check that you have installed Ruby correctly, run the following commands:
rbenv local # you should see this output: # 3.3.0 rbenv shell # you should also see this output: # 3.3.0
- If you get errors like
rbenv: no shell-specific version configured
, you need to set the version for the local or shell environments. To do so, run eitherrbenv shell 3.3.0
orrbenv local 3.3.0
.
- To check that you have installed Ruby correctly, run the following commands:
At this point, you should have:
- A working Terminal with Github working on the command line.
- A local version of this application on your machine.
- rbenv and Ruby 3.3.0 installed on your device.
IMPORTANT: If you are stuck for more than 15 minutes during setup or encounter any unexpected errors, please speak to one of the tutors.
In this section, you will:
- Install PostgreSQL database software via Homebrew.
- Install application dependencies.
- Setup the database.
- Launch the app on
localhost:3000
.
To install PostgreSQL, use the following commands in your terminal:
Read more about PostgreSQL setup here
brew install postgresql@15 libpq
brew link --force libpq
- To check that you have installed PostgreSQL correctly, run the following:
# to login to the default database
psql -d postgres
you should see:
psql (15.x)
Type "help" for help.
postgres=#
to exit, type in \q;
or exit;
(semicolon may not be necessary)
To setup Ruby on Rails
, we will use the Bundler
package manager.
Ideally, open the terminal window in VSCode:
-
Terminal > New Terminal
-
Or,
Ctrl + Shift + Backtick
-
To install
bundler
:
gem install bundler
rbenv rehash
- In the terminal, then run
bundle install
(or justbundle
)- This will install all the application dependencies, including the Ruby on Rails framework
Now that we have PostgreSQL and all our dependencies installed, you need to run the following commands to setup the database.
In the terminal run:
rails db:setup
rails db:migrate
You should see this:
We will know populate the database with some dummy records:
rails db:seed
That's it, the database is setup!
To run the Ruby on Rails Application, run this command in the terminal:
rails server
Navigate to http://127.0.0.1:3000
in your browser. When you do, you will see the server window update - these are your server logs - very important in debugging!
You should be setup to start debugging. Follow the debugging document and try to find and solve each error.
Good luck and happy debugging 🐛