Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby ActiveRecord Basics Migrations and Relationships Migrations

Alberto Rocha
Alberto Rocha
1,013 Points

time columns should be decimal, right?

I see he only uses maximum 1 decimal when writing hours. So I thunk he should user decimal, so we would have a perfomance improvement in the db with thousands of records, right?

1 Answer

Xander Miller
Xander Miller
9,072 Points

ActiveRecord has several data types specifically for handling times and dates:

  • :time
  • :date
  • :datetime
  • :timestamp

Here is great stack overflow question with more in depth answers and handy tables in the answers.

Rails Active Support Core Extensions also makes manipulating times and dates super easy so it would be unwise to ever save a unit of time like hours in your database as a decimal or an integer.