The Contact model has default values for the column is_pickup
Contact.new
=> id: 2, email: nil, order_id: nil, is_pickup: true
Now i am connecting the contact table to the rails db views using scenic gem
class OrderContact < ApplicationRecord
self.table_name = 'temp_contacts'
self.primary_key = :id
...
end
The issue is that i am unable to set default values for the record.
i tried adding the following in the contact model
def is_pickup
self[:is_pickup] || true
end
But still it is not showing up in the rails console
Contact.new
=> id: 2, email: nil, order_id: nil, is_pickup: nil
I need to set the default value when the record is initialised.
Any idea on how to set default values for the model when using db views?