Introduction

Ruby on Rails is a popular model-view-controller web development framework that emphasizes DRY (don’t repeat yourself) and CoC (convention over configuration). What this means is that Rails developers believe that there is a certain ‘Rails’ way to do things which results in clean, easy to read, and maintainable code.

Accessing Your Application

If you point your browser to your public IP address, you should see a page titled ‘Stack Harbor Sample Rails Application’ We’ve provided this sample rails application for you so that you know that you have a working Rails environment on your Server.

This probably isn’t all you want to do with your Rails stack though. We’ve preconfigured the Rails stack to include a script that will remove the sample Rails application we’ve configured and begin running a skeleton rails application out of the /home/rails directory. To run the script, simply execute newrails and follow the instructions provided by the script.

Developing the Skeleton Application

Once you’ve run the newrails script and provided it with your application name, it is up to you to begin developing the application to your liking. You will need to at least generate a root controller and view to handle visits to the homepage of your application. The Rails developers have provided us with instructions showing us how to do just this. Once you’ve generated the welcome controller and index action, you can run the production server by running start [APPLICATION_NAME] replacing [APPLICATION_NAME] with the application name you provided the newrails script. Now, if you point your browser to your Stack’s public IP address, you should see a very simple welcome page.

To stop the application, we have to find the process ID of the web server master process and use the process ID (PID, for short) along with the kill command. Fortunately, we can do this all with one chained command. Execute the following on your Stack:

kill $(ps aux | grep "[u]nicorn master" | awk '{ print $2 }')

The Unix philosophy suggests that if you aren’t shown a multitude of error messages, your command most likely executed correctly. You can verify that the Unicorn web server processes are indeed gone by running ps aux | grep "[u]nicorn master".

Final Words

Congratulations! You have a working development environment in which to being creating web application using Rails. Check out the Rails documentation or browse our Community Section to get more information on how to get started with Ruby on Rails. From us at Stack Harbor, ahoy!