• G
    Add :default option to belongs_to (#28453) · 73b86ac5
    George Claghorn 提交于
    Use it to specify that an association should be initialized with a
    particular record before validation. For example:
    
        # Before
        belongs_to :account
        before_validation -> { self.account ||= Current.account }
    
        # After
        belongs_to :account, default: -> { Current.account }
    73b86ac5
belongs_to_associations_test.rb 35.2 KB