7

I know that Rails datatypes can be found here:

Rails 4: List of available datatypes

or here:

http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column

but what I can't find is a clear definition of each, and the differences between, say, a float versus a decimal, or a string versus text.

Where can I find in-depth definitions of the datatypes?

Community
  • 1
  • 1
Choylton B. Higginbottom
  • 2,236
  • 3
  • 24
  • 34

2 Answers2

10

Here's a good set of definitions (from https://stackoverflow.com/a/15316528/2128691)

  • binary - is for storing data such as images, audio, or movies.
  • boolean - is for storing true or false values.
  • date - store only the date
  • datetime - store the date and time into a column.
  • decimal - is for decimals.
  • float - is for decimals. (What's the difference between decimal and float?)
  • integer - is for whole numbers.
  • primary_key - unique key that can uniquely identify each row in a table
  • string - is for small data types such as a title. (Should you choose string or text?)
  • text - is for longer pieces of textual data, such as a paragraph of information.
  • time - is for time only
  • timestamp - for storing date and time into a column.
Community
  • 1
  • 1
dax
  • 10,779
  • 8
  • 51
  • 86
2

Rails is built on the Ruby language, so try searching for Ruby datatypes instead!

http://www.rubybacon.com/ruby-data-types/ (link no longer working)

Updated link

http://ruby-for-beginners.rubymonstas.org/built_in_classes.html

Tyler
  • 11,272
  • 9
  • 65
  • 105