Ruby on Rails FAQ
Introduction
Configuring Ruby on Rails is inherently more involved that getting a PHP webapp running. This text is intended to be a guide to getting Rails up and running in our environment. It is not intended to be a tutorial for either Ruby or Rails and assumes a basic familiarity with the framework.
Choosing Your Deployment Method
The first question is if you intend to deploy an application worldwide, or if this is simply a development project. For development projects, the server bundled with rails (WEBrick) is adequate. Rails is installed in /usr/local for all departmental 64-bit Linux 2.6 systems. However, in addition to being extremely lightweight, WEBrick does not provide a globally note en URL. Therefore, if you intend to deploy your application for others you will need to request a URL on the department server through tech (more on this later). In any case, the initial steps are the same.
Initial Setup
Choose the database(s) associated with your application before starting. The rails convention is for the database name to match the name of the application, followed
by the name of the environment they apply to. That is, for an application called myAwesomeApp rails normally uses three databases "myAwesomeApp_production",
"myAwesomeApp_development" and myAwesomeApp_test". Presuming that you want to use the departments MySQL server, you will need to request that tech create the appropiate
databases for you. Once this is done, create your application with the rails command.
ex:
rails -dmysql myAwesomeApp
Important: The application should NOT be created inside your ~/public directory. Doing so will create a large security vulnerability!
Once this is done, is it extremely important that you set the OpenAFS permissions of all folders except the public folder so that the webserver has access to them, and
that regular users do not have access to any directory besides the public dir. ex:
find ~/myAwesomeApp/ -type d -exec fs sa {} system:entail none \;After setting the correct permissions, edit ~/myAwesomeApp/Configuration/database.yml with the correct values.
find ~/myAwesomeApp/ -type d -exec fs sa {} webserver rl\;
find ~/myAwesomeApp/ -type d -name public -exec fs sa {} system:anyuser rl \;
Deploying with WEBrick
If you are only planning on deploying via WEBrick, you should be ready to go now. Note that the instructions above do not entail actually creating an functioning app. That part is still up to you. WEBrick runs on port 3000 by default. It is started with (while in the applications root directory) "ruby script/server". The firewalls on the Element's systems will not pass inbound traffic to this port, so the best way to access this port is to establish a remote X connection to the machine you are working on, then point a browser to http://localhost:3000. The Element's systems are obviously multiuser systems, so it is always possible that something else will be using port 3000, WEBrick will fail to start in this case. However, it can be started on a different port with the -p option. Since the elements machines are shared systems, we ask that you not leave instinces of WEBrick running when you are not actively working on your application.
Deploying to the Departmental Webserver
If you want your application to be accessible from the outside world, you will need to deploy it on our webserver. This requires an edit to the webserver configuration files and must be done by tech. Send tech a message with a basic explanation of your application, the full path to the root directory of the application, and any desired name for it. We will provide you with the URL where you application can be accessed.
Your application must be configured to run in the same mode as the server in order to work. I.e. if the server is running in production mode and your application is in development mode, rails will return an error (and very little explanation of the cause). Currently the webserver is running in development mode
Written by Christian Mason. Last modified April 28, 2010





