The goal of this homework is to ensure that you have a functioning Rails development environment with which to complete the remaining Boot Camp homeworks. To accomplish this goal, you must set up a development environment as per the following instructions.
Before I jump into the instructions, I need to clear up a little terminology. In this and future homeworks, you will be using a virtual machine (VM). A VM is where one OS is run inside of another OS (rather than directly on a physical machine). The parent OS is called the host OS. For example, imagine you have a Windows computer—that’ll be the host OS. You can use the VirtualBox software to install a Linux OS within the host Windows OS and to run a Linux VM as if it were a Windows program.
If you are doing this homework using the university Wi-Fi, make sure that you are using the “um” network. Do not use the “um-guest” network, which has ports blocked that are needed for some of the commands below to work properly.
Activate your Piazza account (http://piazza.com/) for the course. You should have received an email invitation (sent to your university email address). If did you not receive an email, contact the instructor. If you run into any technical problem or have any question during the course, post your question to Piazza (Q&A). The instructor as well as your fellow students have the opportunity to answer your question. Moreover, other students will be able to see your question and the answer, saving them the time and trouble of asking the same question.
Sign up for GitHub at https://github.com/ (if you haven’t already previously done so). Be sure not to lose your GitHub username and password.
Rails
Ruby
erb
markdownlint
Markdown PDF
Code Spell Checker
You will need to have a Bash shell with SSH client. Windows users should download and install Git for the Windows platform (http://git-scm.com/download/win), which comes with a Bash shell and SSH client. OSX users have this software by default. Debian/Ubuntu Linux users have the shell, but may need to install the “openssh-client” package (if it’s not already installed by default).
Download and install VirtualBox (https://www.virtualbox.org/). You will be using this software to run an Ubuntu Linux virtual machine. This VM will house the majority of your Rails development tools. All students in this course must use an Ubuntu development environment. The rationale is that by having all students standardize on an environment, they will be better able to collaborate and learn from one another.
Download and install Vagrant (https://www.vagrantup.com/). Vagrant is used to package, distribute, and run custom-configured VMs. I have prepared a Vagrant “box” for you as you will see below.
Create a folder called “workspace”. This folder is where all your Rails projects for the course will go.
Download the file Vagrantfile and save it in your workspace
folder. To do so, you may be able to right-click on this hyperlink and select “Save Link As…” (or similar) from the context menu. Make sure that no file suffix (e.g., “.txt”) gets added to your Vagrantfile.
Launch a terminal. In Windows, it involves launching “Git Bash”. In OSX, this involves launching the “Terminal” app. I assume that Linux users need no clarification here.
In the terminal, change directory (using the cd
command) to the workspace
folder. Note: We will be using the command-line a lot this semester. If you’re new to the command-line, I highly suggest you spend some time on your own learning about it—for example, Codecademy has a course: https://www.codecademy.com/learn/learn-the-command-line
Run the command vagrant up
to download and initialize a Vagrant box. BEWARE! This command (1) may take a long time to complete, (2) downloads a big file (~700MB), and (3) performs at least one processor-intensive compilation (of Ruby). Also, this command will not complete correctly if you are on the “um-guest” network. If using the campus Wi-Fi, use the “um” network. Once this command completes, you will have a running Ubuntu Linux VM (headless).
Run the command vagrant ssh
to SSH into the Linux VM. If you’re prompted for a passphrase, just hit enter. If you’re prompted for a password, enter “vagrant” (without the quotes).
You should see a command prompt that looks like this: [vagrant@ubuntu-xenial:~]
followed by a $
prompt. If you use the ls -l
command, you will see a list of files in the current directory. You will see among them a workspace
folder (actually a symbolic link to the folder /vagrant
).
Change directory (using the cd
command) to the workspace
folder. Note that this folder is synced with the workspace
folder on your host OS. That is, changes you make in the folder on either side (VM or host OS) are instantly applied to the other side.
Enter the command git clone https://github.com/sdflem/sample_app.git
to use Git to download an example project. You should now see a “sample_app” folder inside the workspace
folder. Note that the workspace
folder is synced with your host OS, so you should also see sample_app in your host file explorer. The reason for syncing this folder is that it will later enable you to use a GUI code editor to work on your code files.
Change directory (using the cd
command) to the sample_app folder. When you run this command, RVM should print a message, which lets you know it’s working. If you don’t see a message from RVM, then something is wrong. A common problem is that your terminal application is not configured to run as a “login” shell. This issue seems to come up the most for Linux users, or users of more exotic terminal applications. Typically, the solution can be found in the terminal application’s settings.
gem install bundler
bundle install --without production
rake db:setup
The project comes with some automated tests. Run the command rake test
to execute the tests. You should see that all the tests passed.
Take a screenshot that shows your desktop and terminal with the notification that all the tests passed. Save this screenshot to be submitted later.
Start up the Rails web app server with the command rails s -b 0.0.0.0
(those are zeros). You should see that the server has started without error. Note that this command will not “return” like other commands—that is the command prompt will not reappear until you kill the process (covered below).
Now open the URL http://localhost:3000 in a web browser. A “Welcome to the Sample App” web page should appear.
In the web app, log in with the email example@railstutorial.org
and the password foobar
. You will see that it is a twitter-like app.
In the app, create a post that contains your university email username (e.g., “sdflming rocks!”). Hint: You may need to click the “Home” link.
Congratulations! You’ve completed the main part of this homework.
To shut down everything:
Back in the terminal, type Ctrl-C to kill the Rails server.
Enter the command exit
to logout of the VM.
Enter the command vagrant halt
to shut down the VM.
Later, when you need to start the VM again, just run vagrant up
(should be much faster than last time) and use vagrant ssh
to log in again.
To get credit for completing this homework assignment:
Upload your two screenshots to the appropriate eCourseware dropbox before the posted deadline.
Upload a text document that contains your GitHub username to that same eCourseware dropbox.
Make sure that you have activated your Piazza account (http://piazza.com/) for the course. The instructor will check this using Piazza.
Full marks: 100
Below, the top-level number is the items total point value. If an item is not submitted at all, 0 points will be awarded for that item. The sub-bullets indicate standard deductions for errors in a submitted item. The deduction list below may not be complete because there may be mistakes that we did not expect. The deduction for an unexpected mistake will be assessed at the time it’s discovered and will reflect how severe the instructor thinks the mistake is.
25 Testing screenshot
Other deductions:
.txt