Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlberto Rocha
1,013 Pointstime 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
9,072 PointsActiveRecord 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.