Turn Cloud9 Into a Server


Look inside the main Rails folder called "blog". You will see a file called "Gemfile".

In that file, look for a line that says:
gem 'sqlite3'
Update that line so that it says:
gem 'sqlite3', '1.3.13'
Through out the course, you may make changes to this file and even move that line of code within the file. However, always ensure that it has the version number '1.3.13' next to it like above. Software versions change over time, but by putting that version number there, you'll ensure that your application works exactly as shown in the videos.

After you've updated that line of code in the Gemfile, in the Terminal/Console enter the following commands:
cd environment
cd blog
bundle install
bundle update
Please note that in the video, you'll see the word "workspace", however, in the AWS version of Cloud9 you should simply mentally substitute this for the word "environment". So, anytime you see the instructor type the word workspace, type environment instead. While you'll be reminded again, please note that this applies throughout the remainder of this course. Now you're all set to move on with the lesson!

= Not Started
= Started
= Completed

Just to be extra clear, what we're doing in this video is typing a few Linux commands to activate (i.e. startup) our web application. Your folder structure might look slightly different than the one in the video, and that's okay. This is a good opportunity for you to learn a few Linux commands so that you're comfortable. First, type this into your terminal prompt:
and hit enter. That will make your command prompt "jump" to the highest folder level.

Now run the following command (i.e. type this into the terminal and press enter):
  cd environment

This makes your prompt "jump" one level deeper, into your main folder. Let's break this down. The cd command stands for "change directory" and it expects a folder name of any existing folder that is visible to the prompt. The catch here is that you didn't type in the folder name, but rather the word environment. Amazon has setup Cloud9 so that your main folder (no matter what you named it when you created your Cloud9 environment) is referred to as environment - in the video, since a slightly older version of Cloud9 was used, that folder used to be referred to as workspace, so in the following lessons, although you'll see the instructor typing the word workspace, you should be typing the word environment instead.
Now run the following command:
  cd blog

Now your prompt has "jumped" yet again one level deeper into a folder called blog. You were able to "jump" into this folder because it sits directly one level underneath your main (environment) folder. You can, however, jump multiple levels deep with one command. Try the following. First, jump all the way out to the top level:

Now run this command:
  cd environment/blog

The prompt hops right into your main folder and immediately hops one folder deeper into the blog folder.
If you want to hop back one level higher, simply run:
  cd ..

There, now you're back in the main folder.

Now to startup your Rails application, you need to be inside your main blog folder, because that is where all the Ruby on Rails code resides (remember, Ruby on Rails is just a name for a language and framework for building web applications - Ruby is the language and Rails is the framework. A framework is just a bunch of files and folders that are pre-written for you to save you time and make web development a bit easier - it's like having a toolbelt when you're building a house). So, now, let's jump back into the blog folder:
  cd blog

From here you can run the following command:
  rails server

In the video, you'll see the instructor run rails server -b $IP -p $PORT - you don't have to write that full command however. Again, that was required with the old version of Cloud9, but now you can simply write rails server or even just rails s for a more shorthand version of the command.

This command boots up your Rails application and your terminal window essentially becomes a logger for your application, logging any traffic on your site.

To view your actual site, you need to go to the top of the screen and click the "Preview" button, which displays a dropdown from which you should click "Preview Running Application". A miniature browser window should pop up, but you may not be able to see your site. From here, click the arrow button on the right side of the panel - this should pop open your Rails app in a new browser tab.
You should see the main Rails welcome screen - again, it may look a little different from the video, but as long as the page loaded and it looks like a Rails welcome screen, you're all set!