Basic Web Application
Created by Myriam Leggieri, @iammyr for Rails Girls Galway The basic guides that have been merged and adapted are the Ruby on Rails Tutorial, the basic RailsGirls app and the tutorials for creating thumbnails, authenticating users, adding design, deploying to OpenShift and adding comments.
Get to know the tools
Text Editor
Sublime Text, Komodo Edit, Vim, Emacs, and Gedit are examples of text editors your can use for writing code and editing files.
Terminal (known as Command Prompt on Windows)
Where you start the rails server and run commands.
Web browser
(Firefox, Safari, Chrome) for viewing your application.
GitHub
Important
It is important that you select the instructions specific to your operating system - the commands you need to run on a Windows computer are slightly different to Mac or Linux. If you’re having trouble check the Operating System switcher at the bottom of the commands.
1.Creating the application
We’re going to create a new Rails app called railsgirls-galway-2014.
First, let’s open a terminal:
- macOS: Open Spotlight, type Terminal and click the Terminal application.
- Windows: Click Start and look for Command Prompt, then click Command Prompt with Ruby and Rails.
- Linux (Ubuntu/Fedora): Search for Terminal on the dash and click Terminal.
Next, type these commands in the terminal:
You can verify that a directory named projects
was created by running the list command: ls
. You should see the projects
directory in the output. Now you want to change the directory you are currently in to the projects
folder by running:
You can verify you are now in an empty directory or folder by again running the ls
command. Now you want to create a new app called railsgirls
by running:
This will create a new app in the folder railsgirls
, so we again want to change the directory to be inside of our rails app by running:
If you run ls
inside of the directory you should see folders such as app
and config
. You can then start the rails server by running:
You can verify that a directory named projects
was created by running the list command: dir
. You should see the projects
directory in the output. Now you want to change the directory you are currently in to the projects
folder by running:
You can verify you are now in an empty directory or folder by again running the dir
command. Now you want to create a new app called railsgirls
by running:
This will create a new app in the folder railsgirls
, so we again want to change the directory to be inside of our rails app by running:
If you run dir
inside of the directory you should see folders such as app
and config
. You can then start the rails server by running:
Open http://localhost:3000 in your browser. You should see “Welcome aboard” page, which means that the generation of your new app worked correctly.
Notice in this window the command prompt is not visible because you are now in the Rails server, the command prompt looks like this:
When the command prompt is not visible you cannot execute new commands. If you try running cd
or another command it will not work. To return to the normal command prompt:
Hit Ctrl+C in the terminal to quit the server.
Coach: Explain what each command does. What is a web application and a server - Slides by @ The skeleteon generated by “rails new” reflects the Model-View-Controller - Slides by @ architectural pattern.