Here is my model defination:
class OrderFrequency < ApplicationRecord
self.table_name = "order_frequencies"
enum frequency_unit: { hour: 1}
end
and migration
class CreateOrderFrequencies < ActiveRecord::Migration[5.2]
def change
create_table :order_frequencies do |t|
t.string :value
t.integer :unit
t.timestamps
end
end
end
So how do I assign unit attribute with enum of frequency_unit?
I cannot do
OrderFrequency.create(value: 'value 123', unit: OrderFrequency.frequency_unit.hour)
What is the correct way to use frequency_unit enum for the unit attribute?
Thanks