Getting Started with Ruby on Rails using LinRails in Ubuntu/Linux
July 7, 2007 – 4:34 pmThis 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.
- Navigate to the directory where you want to create your app
- Install linrails
- /opt/linrails/linrails.sh start
- source /opt/linrails/env.sh
- rails [name of app]
- mysqladmin -u root create [database name]_development
- cd [name of app]
- rake db:migrate
- Create Model(s)
- ruby script/generate model [model name]
- Use a name that is singular, i.e product instead of products
- vi db/migrate/001_create_[model name]s.rb
- Add the details for your table
- See pages 66 and 281-320 [1] for details or take a look at this article online.
- ruby script/generate model [model name]
- rake db:migrate
- Create Controller(s)
- ruby script/generate controller [name of controller]
- I suggest you create admin controllers for each your models so that you quickly have an easy way to manipulate your data.
- Create a scaffold for your controller
ruby script/generate scaffold [name of model] [name of controller]
- Open a new terminal
- Navigate to your [name of app] directory
- ruby script/server
- Open a browser
- Try running http://localhost:3000/[name of controller]
- When you are done
- /opt/linrails/linrails.sh stop
- Go to the terminal where you started up Webrick and hit cntrl-c