Ruby

July 19, 2010: These instructions are currently under review and are potentially inaccurate.

The following are instructions for setting up an application using Ruby on Rails. These instructions are still being tested so let us know if you run into problems.

Note: We will assume that

  • you will replace references to username with your username.
  • you can change (but you don't have to ) references to myapp with the name of your application.
  • you can change (but you don't have to ) references to myappcontroller to the name of your controller.

Log in to webtech.kettering.edu via ssh:

cd ~/public_html
rails --with-dispatchers myapp
edit ~/public_html/myapp/public/.htaccess as follows:
change the following line
AddHandler fastcgi-script .fcgi
to
AddHandler fcgid-script .fcgi
uncomment the following line:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
uncomment and change the following line
# RewriteBase /myrailsapp
to
RewriteBase /~username/myapp/public
where username should be replaced by your username!
edit ~/public_html/myapp/config/environment.rb as follows:
uncomment the following line

config.action_controller.session_store = :active_record_store

save the changes you made to ~/public_html/myapp/config/environment.rb

then edit ~/public_html/myapp/config/database.yml with your database username, password, and database name. Use the same information for production, testing, and development.

save the file and run the following:

rake db:sessions:create
rake db:migrate

then cd ~/public_html/myapp and run
ruby script/generate controller myappcontroller
edit ~/public_html/myapp/app/controllers/myappcontroller_controller.rb
to look something like the following:

class MyappcontrollerController < ApplicationController
   def index
     render:text => "Hello World"
   end
end

edit ~/public_html/myapp/config/routes.rb as follows:
uncomment the following line:
# map.connect '', :controller => "welcome"
and change it to something like
map.connect '', :controller => "myappcontroller", :action => 'index'

If we got everything right then you should be able to see a "Hello World" text when you visit http://webtech.kettering.edu/~username/myapp/public/ substituting your username with username above.