# Newbie question: types?

**URL:** <https://www.ruby-forum.com/t/newbie-question-types/158728>\
**Category:** Rails\
**Created:** [January 27, 2009, 12:02pm UTC](https://www.ruby-forum.com/t/newbie-question-types/158728 "2009-01-27T12:02:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 12:02pm UTC](https://www.ruby-forum.com/t/newbie-question-types/158728/1 "2009-01-27T12:02:26Z")

</div>

Hello RoR veterans.

When looking at the following line in in the RoR getting started  
guide:

script/generate scaffold Post name:string title:string content:text

My first thought was “Nice!! So they demo string and text. What are  
the differences between these two, and what other types are  
available?”

So far I’ve seen the following used in various tutorials and blogs:  
string, text, integer, boolean, and references.

I just wish there were an actual _reference_ page for this. Like  
google made for the AppEngine API:

> **[Python no Google App Engine  |  Documentação do App Engine...](https://cloud.google.com/appengine/docs/python?csw=1&hl=pt-br)**

This (by the way) took me all of 60 seconds to find. I’ve been  
searching for a similar guide in RoR all day and haven’t found squat!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 1:47pm UTC](https://www.ruby-forum.com/t/newbie-question-types/158728/2 "2009-01-27T13:47:34Z")

</div>

Hi Steve,

> My first thought was “Nice!! So they demo string and text. What are  
> the differences between these two, and what other types are  
> available?”

The types Active Record supports  
are :primary\_key, :string, :text, :integer, :float, :decimal, :datetime,  
:timestamp, :time, :date, :binary, :boolean.

(Source: [rails.info](http://guides.rails.info/migrations.html) )

Also, on [api.rubyonrails.org](http://api.rubyonrails.org) I found the following information pretty  
quickly:

> **[ActiveRecord::ConnectionAdapters::TableDefinition](https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html)**
>
> Represents the schema of an SQL table in an abstract way. This class provides methods for manipulating the schema representation.

Generally speaking, you usually find all you need in the Rails guides  
and the API documentation. Now I wish there was some usable way of  
finding answers to questions where you _don’t_ know which part of  
Rails is doing the magic. I’d love to have some documentation based on  
the _topic_, like this here: [PHP: Function Reference - Manual](http://www.php.net/manual/en/funcref.php)

Newbies (like myself!) also tend to be confused at times when trying  
to find out whether our question is a Ruby or a Rails question.  
Thankfully the Rails community is pretty friendly. 🙂

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 7:15pm UTC](https://www.ruby-forum.com/t/newbie-question-types/158728/3 "2009-01-27T19:15:11Z")

</div>

Awesome!! Thanks that helps a lot. One follow-up question, if I may:

From what I’ve read, it seems that “references” are only to be used  
for “belongs\_to” associations? Is it best practice to simply avoid  
using “references” and just manually use (for example):

(Using script/generate)  
customer\_id:integer

(Or manually doing a migration file)  
t.customer\_id :integer

???

I guess my question is: what is recommended best practice for using  
“references”?

Thanks again for your help thortos!

-Steve

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 9:58pm UTC](https://www.ruby-forum.com/t/newbie-question-types/158728/4 "2009-01-27T21:58:46Z")

</div>

There is documentation on the different field types at

> **[ActiveRecord::ConnectionAdapters::Table](https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html#M001780)**
>
> Represents an SQL table in an abstract way for updating a table. Also see TableDefinition and connection.create\_table Available transformations are: change\_table :table do |t| t.primary\_key t.

* * *

Ryan B.  
Mocra - Premier iPhone and Ruby on Rails Consultants  
w - [http://mocra.com](http://mocra.com)  
e - removed\_email\_address@domain.invalid  
p - +61 432 937 289 or +61 7 3102 3237  
skype - radarlistener

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 28, 2009, 6:51am UTC](https://www.ruby-forum.com/t/newbie-question-types/158728/5 "2009-01-28T06:51:11Z")

</div>

Thanks Ryan and thortos!

I found a little more information that I was looking for here (as well  
as at your links):

> **[Active Record Associations — Ruby on Rails Guides](https://guides.rubyonrails.org/association_basics.html#_choosing_between_tt_belongs_to_tt_and_tt_has_one_tt)**
>
> Active Record AssociationsThis guide covers the association features of Active Record.After reading this guide, you will know: How to declare associations between Active Record models. How to understand the various types of Active Record...

Cheers!

-Steve
