Preview:
When you want an optional belongs_to:


1) Just don't add in the field's migration
#migration_file_name.rb
#PLEASE DO NOT DO
null: false 

2) In the model use
#PLEASE DO
belongs_to :community, optional: true
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter