How to Use Ruby on Rails in CSE

Introduction

This page describes how to build a Ruby on Rails (nicknamed 'Rails') site in your CSE home directory.

Ingredients

  • An account on the CSE development web server, cheshire.
  • (Optional) A MySQL account.

Procedure

  1. Login to the CSE development web server:
    
    % ssh cheshire
    
    
  2. Change directory to your public_html directory:
    
    % cd public_html
    
    
  3. Create a new Rails application. I've arbitrarily titled it RoR_Blog. This step installs most of your application's Ruby on Rails web application framework files into this directory.
    
    ~/public_html% rails new RoR_Blog
    
    
  4. Symlink your Rails application's public directory to the name by which you'll refer to the application on the web:
    
    ~/public_html% ln -s RoR_Blog/public foo
    
    
  5. Test. You should see the beginnings of a Ruby on Rails application:
    
    http://www-student.cse.buffalo.edu/~userid/foo
    
    
  6. Create this web application's database. This will create your development and test SQLite3 databases inside the db/ folder:
    
    ~/public_html% cd RoR_Blog
    RoR_Blog% rake db:create
    
    
  7. Create a Controller and a View:
    
    RoR_Blog% rails generate controller home index
          create  app/controllers/home_controller.rb
           route  get "home/index"
          invoke  erb
          create    app/views/home
          create    app/views/home/index.html.erb
          invoke  test_unit
          create    test/functional/home_controller_test.rb
          invoke  helper
          create    app/helpers/home_helper.rb
          invoke    test_unit
          create      test/unit/helpers/home_helper_test.rb
          invoke  assets
          invoke    coffee
          create      app/assets/javascripts/home.js.coffee
          invoke    scss
          create      app/assets/stylesheets/home.css.scss
    
    
  8. Figure out how to get Apache and Phusion Passenger (mod_rails) configured to serve RoR apps in per-user public_html directories.
  9. AllowOverride Options is on in user home directories, so configure RailsBaseURI/RackBaseURI in .htaccess files? Disable MultiViews.

References

  1. http://guides.rubyonrails.org/getting_started.html
  2. http://www.modrails.com/documentation/Users%20guide%20Apache.html