Scaleway Documentationtutorials
ruby on rails instant app

Jump toUpdate content

Getting started with the Ruby on Rails InstantApp

Reviewed on 10 May 2021Published on 28 July 2015
  • compute
  • ruby
  • rails
  • apps

Ruby on Rails InstantApp - Overview

The intended audience of this image is Rails developers who want to bootstrap or test a Rails application easily, in seconds.

Common packages have been installed:

  • Nginx
  • Ruby
  • RVM
  • Rails
  • Unicorn
  • Node.js

Requirements

Create and start a new instance using the Ruby on Rails InstantApp

Before starting, click the “Create a Server” button in the control panel.

You will land on the server-creation page where you can choose the Ruby on Rails image in the InstantApps tab for your Cloud Instance:

Choose the server type and click the Create a Server button. This action starts your server.

Run a Ruby on Rails web application

Log-in to your server with the following command:

{% highlight sh %} $> ssh -i /path/to/key root@<your_server_ip> {% endhighlight %}

Once connected to the server, log-in as rails user:

{% highlight sh %} $> su rails $> source /etc/profile {% endhighlight %}

In the home directory of rails user /home/rails, you will find the default directory containing a fresh rails application. You can use it to bootstrap your rails project.

Unicorn is configured to serve the default Rails application in /home/rails/default.

You can access the Rails application via your browser at http://your_server_ip to view the default app website!

If you want to create a new Rails application, you will have to perform some actions to get it running with unicorn:

{% anchor h4%} Create a new Rail application

{% highlight sh %} $> rails new yourapplicationname {% endhighlight %}

{% anchor h4%} Generate SECRET_KEY_BASE

{% highlight sh %} $> rake -f /home/rails/yourapplicationame/Rakefile secret {% endhighlight %}

{% anchor h4%} Edit Unicorn configuration

Open the file /etc/default/unicorn to change the working directory and SECRET_KEY_BASE.

Set application working directory to APP_ROOT=/home/rails/yourapplicationame and SECRET_KEY_BASE value to the key generated previously.

Then in /etc/unicorn.conf change the working_directory value to /home/rails/yourapplicationame.

Restart Unicorn as root user and you can open your browser and visit your IP to view your super new application!

{% highlight sh %} $> service unicorn restart {% endhighlight %}

Conclusion

Useful links:

This image doesn’t contain databases, because we can’t really know which one you prefer.

To install MySQL, run:

{% highlight sh %} $> apt-get install mysql-server {% endhighlight %}

And/or PostgreSQL:

{% highlight sh %} $> apt-get install postgresql {% endhighlight %}

{% anchor h4 %} Suggestions

If you think something is missing in this image, or if it would have been easier if you had this or that tool, or if this <whatever> should be configured that way instead of how it currently is, we’d love to hear from you!