Searching a Database in Rails

For searching your database, ActiveRecord (AR) provides many methods – some generated automatically based on your tables. The most basic way to find an object is with calling the class method ‘find’ on your model. find, by default, takes the id(s) of the record you’re looking for as an argument.
User.find(1)
User.find(1, 7, 14)

You can find the [...]

Posted at 12am on 9/27/09 | 3 comments | Filed Under: Uncategorized | read on

Rails Migration Data Types

Had someone ask where to find the available data types for Rails migrations today – and thought it would be good to keep a copy for my own reference. Heres the list:
Rails -> MySQL
:binary -> blob
:boolean -> tinyint(1)
:date -> date
:datetime ->datetime
:decimal -> decimal
:float ->float
:integer -> int(11)
:string -> varchar(255)
:text -> text
:timestamp -> datetime
:time -> time

Posted at 3pm on 5/29/09 | 1 comment | Filed Under: Uncategorized | Tagged: | read on

About

My name is Jared Fraser. I’m a Web Developer and Rails Teacher located in Canberra, Australia. You might ask why I am in Canberra, and I am unable to tell you. You’ll have to make up your own backstory for me.

Categories