Getting Started with Ruby on Rails using LinRails in Ubuntu/Linux

July 7, 2007 – 4:34 pm

This brief guide will get a bare bones Ruby and Application up and running using Linrails. I suggest that you then take a look at Agile Web Development with Rails Second Edition and do the Depot tutorial.

  1. Navigate to the directory where you want to create your app
  2. Install linrails
  3. /opt/linrails/linrails.sh start
  4. source /opt/linrails/env.sh
  5. rails [name of app]
  6. mysqladmin -u root create [database name]_development
  7. cd [name of app]
  8. rake db:migrate
  9. Create Model(s)
    1. ruby script/generate model [model name]
      1. Use a name that is singular, i.e product instead of products
    1. vi db/migrate/001_create_[model name]s.rb
      1. Add the details for your table
      2. See pages 66 and 281-320 [1] for details or take a look at this article online.
  10. rake db:migrate
  11. Create Controller(s)
    1. ruby script/generate controller [name of controller]
    2. I suggest you create admin controllers for each your models so that you quickly have an easy way to manipulate your data.
    3. Create a scaffold for your controller
      1. ruby script/generate scaffold [name of model] [name of controller]
  12. Open a new terminal
    1. Navigate to your [name of app] directory
    2. ruby script/server
  13. Open a browser
    1. Try running http://localhost:3000/[name of controller]
  14. When you are done
    1. /opt/linrails/linrails.sh stop
    2. Go to the terminal where you started up Webrick and hit cntrl-c

[1] Agile Web Development with Rails Second Edition

Post a Comment