Skip to content

2. Project Setup

TecOrb Technologies edited this page Oct 5, 2022 · 1 revision

Required dependencies:

  • Ruby is installed (v 3.0.1)
  • Rails is installed (v 6.1.4)
  • MySQL is installed
  • Git is installed
  • GitHub account is created

Major steps are followed to setup:

  • Setup a new Rails app
  • Database configuration setup (using MySQL)
  • Initialize a local repository using git
  • .gitignore file created to add configuration.yml
  • configuration.yml file created to initialize environment variables
  • Create a new remote repository using GitHub
  • Change README.md and documentation added
  • Code Commited and Pushed to GitHub repository

Project Setup

Navigate to the directory in which you want the new app created using 'change directory' (cd).

Use the 'make directory' (mkdir) command if you want to create a new directory, such as rails_projects (Note: Rails will automatically create a directory for all your app files)

  $ cd <correct_directory>  

Create a new app. It's good practice to append your new app name with '_app' so that it will not be confused with any classes you create later.

The 'rails new' command will create the default Rails file structure inside a directory with the name you gave in the command above

  $ rails new <new_app> 

Navigate to the newly created directory using 'cd'

  $ cd <new_app> 

Initialize a git repository

Initialize a new git repository locally
(This initializes a repository in the current working directory, so ensure you are in the correct one.)

  $ git init  

Add everything in the current directory to the repository

  $ git add .   

OPTIONAL - Check git status to show you what is currently in the 'staging area'

  $ git status 

Commit all the changes in the 'staging area' to the LOCAL git repository and add a comment

  $ git commit -m "Initial commit" 

OPTIONAL - Check the log to show a list of commit messages

  $ git log                                               

Create a new GitHub repository and set as master branch

Create a new GitHub repository

  # Log in to GitHub 

  # Select 'New repository' or navigate to https://github.com/new

  # Add a Repository name that matches your app name (<new_app>) 

  # Deselect 'Initialize this repository with a README.

Tell git to add Github as the origin for the 'master' branch

  $ git remote add origin git@github.com:<username>/<new_app>.git           

Push the local repository up to Github (the remote repository)

  $ git push -u origin main 

Change README.rdoc, commit and push the change

Open README.rdoc in textmate

  $ mate README.rdoc      
                                      
  # Replace default info with info relevant to your app

Commit all (-a) modifications with a comment (-m) about what was changed
[Use 'git add' first if new files were created]

  $ git push                                      

Push locally commited changes to Github
[Can skip 'origin master' b/c one push was done above]

  $ git commit -a -m "Improve the README file"  

Clone this wiki locally