Ruby on Rails Installation Guide

Support for the Ruby on Rails web framework is included with our Advanced and Corporate packages. This guide describes the procedure to quickly set up Rails under your account.

Check that Rails is installed on your server

Due to differing versions in existing software, Rails is not available on all of our servers. To see if Rails is installed on yours, use the rails --version command from your shell. If it is not installed, you can request that your account be transferred to a server that supports it.

Create your application skeleton

Use the rails command to create the skeleton for your application and start the server. Use your assigned v-host IP address as the -b argument, and the port number 8080:

  $ rails www/my-app
  $ cd www/my-app
  $ ruby script/server -b 96.47.74.x -p 8080

You can now connect to http://96.47.74.x:8080 using your browser. This is a temporary URL, please use it for configuration/test purposes only. We do not manage/prioritize traffic to port 8080 so it is not guaranteed to be fast.

Note that script/server should be used only for testing purposes, it is not a production web server.

Create your databases

If you have not already done so, use csoftadm to create the dev, test and prod databases. You can do this from the "Databases" section of the Control Panel, or alternatively using the db commands with the Shell Interface, like so:

  $ csoftadm -c 'db add dev localhost'
  initial password? somepassword
  rights? SELECT,INSERT,... (enter)
  Added database user dev@localhost (SELECT,INSERT,...)

  $ csoftadm -c 'db add test localhost'
  $ csoftadm -c 'db add prod localhost'
Edit config/database.yml

In your Rails application directory, edit the file config/database.yml. Remember that your username is prepended to your database name and database user. An entry for a MySQL database might look like:

development:
  adapter: mysql
  database: myname_dev
  username: myname_dev
  password: somepassword
  socket: /var/run/mysql/mysql.sock

test:
  adapter: mysql
  database: myname_test
  username: myname_test
  password: somepassword
  socket: /var/run/mysql/mysql.sock

production:
  adapter: mysql
  database: myname_prod
  username: myname_prod
  password: somepassword
  socket: /var/run/mysql/mysql.sock

Make sure to remove the other example entries from database.yml. Now shutdown the Rails server, either with ctrl-c or kill, and restart it with the same command line.

Create your application

You can use the script/generate command without arguments to see the available generator options. Installed generators are controller, mailer, migration, model, plugin, scaffold, session_migration and web_service. You can download additional generators from this page.

The default index file is public/index.html. You can change that by editing config/routes.rb.

Final setup

From your shell, use crontab -e to open up your crontab in your favorite text editor, and append the following line, which will ensure that your server is started whenever the machines hosting your account are rebooted.

  @reboot (cd $HOME/www/my-app && ruby script/server -b 96.47.74.x -p 8080)

Once your application is ready, request to tech support that the port 80 of your v-host be redirected to your Rails server. We will also perform a few additional steps needed to set up redundancy such that a backup server will automatically start up your server if there is a failure.


Csoft.net
© 2024 CubeSoft Communications
All Rights Reserved.