Im working on learning Rails, and have found that the details are where you can really end up sinking yourself in the future. As I'm creating a very simple store, doing migrations I have a few belongs_to's that are optional object relationships. As I was reading trying to better understand null here:
Understanding rails migration statement (:null => false)
It occurred to me that using null: true would allow that column to be null, and I was couldn't find any information / questions addressing the difference between:
create_table :items do |t|
...
t.belongs_to :shopping_cart, null: true
...
end
and
create_table :items do |t|
...
t.belongs_to :shopping_cart, optional: true
...
end
What should I be doing for this kind of optional relationship, I'm new to Ruby/Rails but "convention over configuration" has me wanting to understand the right way to do this. Thanks so much!