Rails Note #1: Getting my feet wet in Ruby On Rails
-
Just installed Ruby and Rails on my MacOSX Leopard. The current version of rails is 1.2.6. I wanted to upgrade using gem update –system but it seems like taking forever.. So I did a manual install of ruby, rubygems then rails..
-
The tutorial that I followed was from http://hivelogic.com/articles/2008/02/ruby-rails-leopard
Installation Summary
2.1 ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p286.tar.gz tar -zxvf ruby-1.8.6-p286.tar.gz ./configure make make install |
2.2 rubygems
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz tar -zxvf rubygems-1.3.1.tgz ruby setup.rb |
2.3 rails
gem install -V rails |
2.4 other gems
gem install rubygems-update gem install mongrel gem install capistrano gem install postgres gem install builder |
-
Browsed the first few pages of the hilarious http://www.poignantguide.net/ruby
-
Went for a book. Found Simply Rails 2.0 on Boox24x7 and Safari. Added that to my shelf and read chapters 1 – 5 on my first night.
-
Was able to setup database configuration in config/database.yml using Postgres. I have yet to study how oracle works.
-
rake db:migrate is a convenient way of building your database schema without using SQL. Simply Rails 2.0:Chapter 5:Generating a Model introduced inserting records using script/console
-
URL Helpers for Story Resource
stories_path /stories
new_story_path /stories/new
story_path(@story) /stories/1
edit_story_path(@story) /stories/1/edit
Remember to define the route in config/routes.rb
map.resources :users, :categories
- Naming Conventions
Variables – lowercase letters and words separated by underscores.
i.e name, country_of_origin
DB Table and Column names should follow convention is always pluralised.
i.e users
Classes and Modules – no underscores and each word is capitalized
i.e User, UserCategories