How to create a Rails 5 application from zero

13 de julio, 2016 @ 13:58 — 0 comentariosDownload PDF

In this guide we explain how to create and deploy a Ruby on Rails 5.0 application.

Note that you require SSH access and access to compilers.

1 - Define the app from the Hosting Panel

1 - Access your Hosting Panel

Just follow instruccions of How to access your Hosting Panel.

2 - Click on Ruby Applications

Look for and click on Ruby Applications icon.


3 - Define the app

Fill in the form and make sure you choose Ruby Hai or Ruby Kon stack:


Once you submit the form you we'll see the app creation result. Remember the application directory as it's important in the next steps.


2 - Install Rails and Bundler gems

Install the 5.0 version on Ruby on Rails:

gem install rails -v5.0

When installing Rails 5.0 Bundler should have been installed, but if for some reason tBundler has not been installed, run:

gem install bundler

3 - Create the application

In the first step you have defined the application, therefore you should known the it's named and directory.

Suppose that the application's name is myapp and the directory is /home/username/ruby/myapp, run the following to create the application:

cd ruby
rm -fr myapp
rails new myapp

4 - Fix ExecJS

Edit ~/ruby/gems/gems/execjs-2.5.2/lib/execjs/runtimes.rb and search for ( name: "Node.js (V8)" )

This section shloud be corrected as follow:

Node =
     name: "Node.js (V8)",
     command: "/opt/nodejs-8/bin/node",
     runner_path: ExecJS.root + "/support/node_runner.js",
     encoding: 'UTF-8'

5 - Install dependencies

Now it's time to install the application dependecies:

cd ruby/myapp
bundler install

6 - Restart application

cd ruby/myapp
touch tmp/restart.txt

7 - Verify installation

Access your website to verify that previous steps are correct. You should see a Rails error message such as:


8 - Create a Welcome page

Just run:

rails generate controller welcome index

9 - Customize the Welcome message

Open the view file created in the previous step:

nano app/views/welcome/index.html.erb

Delete all it's content and add:

<h1>Hola, Rails!</h1>

10 - Configure routes

We want to show the previous message in the root of the domain. In order to do that, open the config/routes.rb file:

nano config/routes.rb

And replace this line:

#root 'welcome#index'


root 'welcome#index'

11 - Restart application

touch tmp/restart.txt

12 - Access your website