Wednesday, January 26, 2005

Ultra simple Ruby on Rails tutorial

Assumptions are mysql is installed along with ruby and rails

In mysql:

createdb TEST;
create table TEST.test (id int key auto_increment, title varchar(10) not null);

Then execute:
rails test
cd test

Now update config/database.yml

Execute:
ruby script/generate model test
ruby script/generate controller test

edit app/controllers/test_controller.rb:

class TestController <>

scaffold :test

end

Edit config/environment.rb:
ActiveRecord::Base.pluralize_table_names = false


Browse to:
http://localhost:3000/test/list

BING, instant CRUD!

No comments: