Archive for the 'ruby' Category
Reduce Annoying “requires” in ruby’s irb

It is quite annoying to use require again and again while testing anything in irb.
For that purpose it is useful to create a file called .irbrc in the home directory.
Here simply write sth like this:

require ‘rubygems’
require ’socket’

Now every time you start irb the packages are loaded by default.

For windows it is also necessary to have an appropriate HOME Variable pointing to the right directory.

Migration data types / column types

The data types or columns types as they are called are little bit hard to find for somebody who ist not yet really familiar with rails language.
Now here what I found about this:

The columns types are:

:integer
:float
:datetime - default format: ‘2007-07-06 17:05:22′
:date - default format: ‘2007-06-07′
:timestamp
:time
:text
:string
:binary
:boolean

According options are:
:limit, e.g. :limit => 32
:default, e.g. :default => “defaultvalue”
:null, e.g. :null => true means its nullable

and for native data types:
:precision, ??
:scale, ??