Types supported by Rails Active Record

I’m always looking for those somewhere on web when I need them. Now I’m posting them here so I will always have them handy. If you need them then you can use this as a reference. Below is a list of supported types with its MySQL representation.

  • :primary_key – int(11) DEFAULT NULL auto_increment PRIMARY KEY
  • :stringvarchar(255)
  • :text – text
  • :integer – int limit 4
  • :float – float
  • :decimal – decimal
  • :datetime – datetime
  • :timestamp – datetime
  • :time – time
  • :date – date
  • :binary – blob
  • :boolean – tinyint(1)

It can also be found in this constant in ActiveRecord ConnectionAdapters MysqlAdapter


I think that all the other type mappings could be found in appropriate ActiveRecord Connection adapters.

Cheers, Gregster

Knights tale of Ruby and Rails

GiguI should be painting the office (one room in our house that is working as a storage room at the moment), but I can’t force myself to start. I’m too lazy to paint but I thought I write about my experience with Ruby and Rails, or in other words, my first steps as a ROR developer.

Yada Yada Yada

Let’s start with Ruby, new programming language for me. So, I don’t need to compile anything to run, it’s interpreted. That’s cool, I used to do a lot of PHP programming some days ago and I liked it a lot. On the other hand, syntax, rules and conventions were weird for me. I did have a conversation with some other developers and they shared my feelings on that subject.

Yoda Yoda Yoda

I got this strange way of learning new programming language. I just get tools and IDE for it, do a little bit of reading and off I go. So, I’m a Linux user, I’ve seen a lot of ROR applications development on Macs using TextMate or something similar. I started to look for some tool for other platform. Ruby comes bundle with Scite. It’s great that it has syntax highlighting but nothing more. For me the most important bit is InteliiSense.

There is no strong typing in Ruby so how any IDE will know what kind of object it’s dealing with. As a result completion is just a list of ALL methods and properties you can associate with anything. That’s not really helping. Oh, by the way, refactoring tools boils down to RENAME 🙂 On the other hand as soon as you know language it keeps you focus as you need to be careful about what your are typing.

Trails of Rails

When I finished with all the setup I kinked off some development. I can’t believe how fast I was able to do things with rails. For a basic web application these framework is just amazing. It comes with generator that creates all single parts of application (model, view, controller, database migration) with skeleton code, inside appropriate folders. I finally selected Netbeans to be my IDE as it seemed to have most reasonable code completion and integrated all script generation.

Book da Book

I can’t use some clever code completion tricks, bottom line: reading books. There are two titles recommended for Ruby and Ruby on Rails by a lot of people (can’t really name a single person at the moment) in Pragmatic Programmers Bookshelf. I can’t say that any of them give me a good kick start. First chapters are dragging for ages and once finished I had impression that I didn’t learn anything. Those books are good language/framework reference though with much better content after first chapter.

Summer (y)

When I started things looked a little bit messy. Strange syntax, no good IDE. After few days of development I started to like it. Language features stopped being annoying and there is more visible results. I will share more experience after few more weeks of development. Stay tuned.