I want to save durations (2 days, 5 years, ...) as intervals in PostgreSQL from my Rails application.
Both duration_min and duration_max are values like "2 days" or "5 years", so each of them is an interval by itself:
def change
create_table :times do |t|
t.interval :duration_min
t.interval :duration_max
t.timestamps
end
end
but the DB migration fails when setting the data type to "interval" and rake returns:
undefined method 'interval' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x007f8615694360>
How do I define the table for it to accept (and understand) an input like "2 days"?