-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Bug: Shipping a project fails with postable can't be blank
Introduced by: #1639 (commit 778654b)
Cause:The commit added validates :postable_id, presence: true to Post. This validation fires before Rails has a chance to persist the associated Post::ShipEvent and assign it an id. Since postable_id is still nil at validation time (the record hasn't been saved yet), the validation fails and the whole transaction is aborted.
Fix: Replace the column-level validations with an association-level one:
# Remove these:
validates :postable_id, presence: true
validates :postable_type, presence: true
# Add this instead:
validates :postable, presence: trueThis validates the object reference rather than the raw foreign key column, so it works correctly with delegated_type's autosave behaviour.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels