Reputation: 353
I'm having a small mindblow, what's the best way to store only time in rails?
Likely I'm having 3 options in my head
What you could suggest to me and why? :)
Postgres 13
Rails 6.0.3
Ruby 2.7.2
Upvotes: 1
Views: 1241
Reputation: 165546
time is a built-in Rails column type which works with Time objects. It will use the Postgres time (without time zone) type.
You can manually use time with time zone
which will also map to Time, but it will retain the time zone.
add_column(:yourtable, :time_at, 'time with time zone')
See It's About Time (Zones) for more about how to work with time in Rails.
Upvotes: 1